Difference between View and ViewGroup in Android

后端 未结 11 1485
暖寄归人
暖寄归人 2020-12-02 08:11

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

相关标签:
11条回答
  • 2020-12-02 08:48

    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.

    0 讨论(0)
  • 2020-12-02 08:53

    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.
    0 讨论(0)
  • 2020-12-02 08:53

    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

    0 讨论(0)
  • 2020-12-02 08:53

    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.

    0 讨论(0)
  • 2020-12-02 08:59

    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.

    0 讨论(0)
提交回复
热议问题