Skip to content
Related Articles

Related Articles

Improve Article

Difference Between View and ViewGroup in Android

  • Last Updated : 17 Mar, 2021

In Android Layout is used to describe the user interface for an app or activity, and it stores the UI elements that will be visible to the user. An android app’s user interface is made up of a series of View and ViewGroup elements. In most cases, android apps will have one or more operations, each of which is a single screen of the app. Multiple UI components will be present in the operations, and those UI components will be instances of the View and ViewGroup subclasses. Generally, the android apps will contain one or more activities and each activity is one screen of the app. The activities will contain multiple UI components and those UI components are the instances of View and ViewGroup subclasses. In Android apps, the two very central classes are the Android View class and ViewGroup class. One or more tasks can be found in an Android app. A screen in an Android operation is identical to the windows in a desktop application. GUI components may be used in an operation. View or ViewGroup subclasses are used to build the GUI elements. 

View is a basic building block of UI (User Interface) in android. A view is a small rectangular box that responds to user inputs. Eg: EditText, Button, CheckBox, etc. ViewGroup is an invisible container of other views (child views) and other ViewGroup. Eg: LinearLayout is a ViewGroup that can contain other views in it. ViewGroup is a special kind of view that is extended from View as its base class. ViewGroup is the base class for layouts. As the name states View is singular and the group of Views is the ViewGroup. In simple terms, a view is a user interface feature that we interact with when we use an app, such as a button, editing text and images, and so on. Android.view has a child class called View. Observe While the View group is the container that houses all of these views as well as many other ViewGroup such as linear or Frame Layout. For example, if we design and use the LinearLayout as the root feature, our main layout would be the LinearLayout. Within it, we can add another view category (i.e. another LinearLayout) and several other views such as buttons or TextViews.

Want a more fast-paced & competitive environment to learn the fundamentals of Android?
Click here to head to a guide uniquely curated by our experts with the aim to make you industry ready in no time!


The View class is the base class or we can say that it is the superclass for all the GUI components in android. For example, the EditText class is used to accept the input from users in android apps, which is a subclass of View, and another example of the TextView class which is used to display text labels in Android apps is also a subclass of View. 

Or the other definition,

View refer to the android.view.View class, which is the base class of all UI classes. android.view.View class is the root of the UI class hierarchy. So from an object point of view, all UI objects are View objects. Following are some of the common View subclasses that will be used in android applications.

These are some of the view subclass available in android. 


The ViewGroup class is a subclass of the View class. And also it will act as a base class for layouts and layouts parameters.  The ViewGroup will provide an invisible container to hold other Views or ViewGroups and to define the layout properties. For example, Linear Layout is the ViewGroup that contains UI controls like Button, TextView, etc., and other layouts also. ViewGroup Refer to the android.view.ViewGroup class, which is the base class of some special UI classes that can contain other View objects as children. Since ViewGroup objects are also View objects, multiple ViewGroup objects and View objects can be organized into an object tree to build a complex UI structure. Following are the commonly used ViewGroup subclasses used in android applications.

The ViewGroup subclasses listed above group View instances together and takes care of their layout. For instance, the LinearLayout will render the components after each other either horizontally or vertically.

View and ViewGroup in Android

Difference Table

                                          View                                                      ViewGroup
View is a simple rectangle box that responds to the user’s actions.ViewGroup is the invisible container. It holds View and ViewGroup
View is the SuperClass of All component like TextView, EditText, ListView, etcViewGroup is a collection of Views(TextView, EditText, ListView, etc..), somewhat like a container.
A View object is a component of the user interface (UI) like a button or a text box, and it’s also called a widget.A ViewGroup object is a layout, that is, a container of other ViewGroup objects (layouts) and View objects (widgets)
Examples are EditText, Button, CheckBox, etc.For example, LinearLayout is the ViewGroup that contains Button(View), and other Layouts also.
View refers to the android.view.View classViewGroup refers to the android.view.ViewGroup class
android.view.View which is the base class of all UI classes.ViewGroup is the base class for Layouts.

So, these all are the basic key difference between the View class and Viewgroup class in Android.

My Personal Notes arrow_drop_up
Recommended Articles
Page :