Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between View and ViewGroup in Android

What is the difference between a View and a ViewGroup in Android programming?

like image 229
user3927549 Avatar asked Dec 08 '14 06:12

user3927549


People also ask

What are view and ViewGroup classes in android?

View is the base class for widgets, which are used to create interactive UI components like buttons, text fields, etc. The ViewGroup is a subclass of View and provides invisible container that hold other Views or other ViewGroups and define their layout properties.

What is a ViewGroup in android?

ViewGroup. A ViewGroup is a special view that can contain other views. The ViewGroup is the base class for Layouts in android, like LinearLayout , RelativeLayout , FrameLayout etc. In other words, ViewGroup is generally used to define the layout in which views(widgets) will be set/arranged/listed on the android screen.

Which is contain views and ViewGroup?

- The view group is the base class for layouts and views containers - For example, RelativeLayout is the ViewGroup that contains TextView(View), and other Layouts also. Show activity on this post. All UI elements in an Android app are built using View and ViewGroup objects.

What is the difference between layout and view in android?

A layout defines the structure for a user interface in your app, such as in an activity. All elements in the layout are built using a hierarchy of View and ViewGroup objects. A View usually draws something the user can see and interact with.


1 Answers

View

  1. View objects are the basic building blocks of User Interface(UI) elements in Android.
  2. View is a simple rectangle box which responds to the user's actions.
  3. Examples are EditText, Button, CheckBox etc..
  4. View refers to the android.view.View class, which is the base class of all UI classes.

ViewGroup

  1. ViewGroup is the invisible container. It holds View and ViewGroup
  2. For example, LinearLayout is the ViewGroup that contains Button(View), and other Layouts also.
  3. ViewGroup is the base class for Layouts.
like image 160
saibaba vali Avatar answered Sep 28 '22 04:09

saibaba vali