Difference between View and ViewGroup in Android

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

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

11条回答
  •  暗喜
    暗喜 (楼主)
    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

提交回复
热议问题