Tech and Media Labs
This site uses cookies to improve the user experience.




Android View and ViewGroup

Jakob Jenkov
Last update: 2014-10-28

The Android View class and ViewGroup class are two very central classes in Android apps. An Android app contains one or more activities. An Android activity is a screen, similar to windows in a desktop application. Inside an activity you can have GUI components. The GUI components are instances of View or ViewGroup subclasses. It may sound a bit abstract at this point, but I will explain both in more detail below.

View

The View class is a superclass for all GUI components in Android. For instance, the TextView class which is used to display text labels in Android apps is a subclass of View. Android contains the following commonly used View subclasses:

  • TextView
  • EditText
  • ImageView
  • ProgressBar
  • Button
  • ImageButton
  • CheckBox
  • DatePicker

These are only some of the many, many subclasses of the View class.

ViewGroup

The ViewGroup class is a subclass of the View class. ViewGroup instances work as containers for View instances to group View instances together. Android contains the following commonly used ViewGroup subclasses:

  • LinearLayout
  • RelativeLayout
  • ListView
  • GridView

These are not the only ViewGroup subclasses Android contains. There are others but which are less used.

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.

Jakob Jenkov




Copyright  Jenkov Aps
Close TOC