View vs Viewgroup in Android

View vs Viewgroup in Android

This image explains the difference simply. image.png

The View class is the base class or we can say that it is the superclass for all the GUI components 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.

Following are some of the common View subclasses that will be used in android applications

  • TextView
  • EditText
  • ImageView
  • RadioButton
  • Button
  • ImageButton
  • CheckBox
  • DatePicker
  • Spinner
  • ProgressBar and etc.

Following are the commonly used ViewGroup subclasses used in android applications

  • FrameLayout
  • WebView
  • ListView
  • GridView
  • LinearLayout
  • RelativeLayout
  • TableLayout

The end

If you liked this make sure to give a follow.