Difference between View and ViewGroup in Android
View
View
objects are the basic building blocks of User Interface(UI) elements in Android.View
is a simple rectangle box which responds to the user's actions.- Examples are
EditText
,Button
,CheckBox
etc.. View
refers to theandroid.view.View
class, which is the base class of all UI classes.
ViewGroup
ViewGroup
is the invisible container. It holdsView
andViewGroup
- For example,
LinearLayout
is theViewGroup
that contains Button(View), and other Layouts also. ViewGroup
is the base class for Layouts.
A
ViewGroup
is a special view that can contain other views (called children.) The view group is the base class for layouts and views containers. This class also defines theViewGroup.LayoutParams
class which serves as the base class for layouts parameters.View
class represents the basic building block for user interface components. A View occupies a rectangular area on the screen and isresponsible for drawing and event handling. View is the base classfor widgets, which are used to create interactive UI components(buttons, text fields, etc.).- Example : ViewGroup (LinearLayout), View (TextView)