What is the difference between a View
and a ViewGroup
in Android programming?
In simple words View is the UI element which we interact with when we use an app,like button,edit text and image etc.View is the child class of Android.view.View While View group is the container which contains all these views inside it in addition to several othe viewgroups like linear or Frame Layout etc. Example if we design & take the root element as Linear layout now our main layout is linear layout inside it we can take another view group (i.e another Linear layout) & many other views like buttons or textview etc.
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.EditText
, Button
, CheckBox
etc..View
refers to the android.view.View
class, which is the base class of all UI classes. ViewGroup
is the invisible container. It holds View
and ViewGroup
LinearLayout
is the ViewGroup
that contains Button(View), and other Layouts also.ViewGroup
is the base class for Layouts.View
is a basic building block of UI
(User Interface) in android. A view is a small rectangular box which responds to user inputs. Eg: EditText
, Button
, CheckBox
, etc..
ViewGroup
is a invisible container of other views (child views) and other viewgroups. Eg: LinearLayout
is a viewgroup which can contain other views in it.
ViewGroup
is a special kind of view which is extended from View as its base class. ViewGroup
is the base class for layouts.
as name states View is singular and the group of Views is the ViewGroup
.
more info: http://www.herongyang.com/Android/View-ViewGroup-Layout-and-Widget.html
View
is the SuperClass of All component like TextView, EditText, ListView,
etc..
while ViewGroup
is Collection of Views(TextView, EditText, ListView, etc..)
, somewhat like container.
ViewGroup
is itself a View
that works as a container for other views. It extends the functionality of View
class in order to provide efficient ways to layout the child views.
For example, LinearLayout
is a ViewGroup
that lets you define the orientation in which you want child views to be laid, that's all you need to do and LinearLayout
will take care of the rest.