Difference between View and ViewGroup in Android

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

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

11条回答
  •  一向
    一向 (楼主)
    2020-12-02 08:41

    1. A ViewGroup is a special view that can contain other views (called children.) The view group is the base class for layouts and views containers. This class also defines the ViewGroup.LayoutParams class which serves as the base class for layouts parameters.

      View class represents the basic building block for user interface components. A View occupies a rectangular area on the screen and is responsible for drawing and event handling. View is the base class for widgets, which are used to create interactive UI components (buttons, text fields, etc.).

    2. Example : ViewGroup (LinearLayout), View (TextView)

    Reference

提交回复
热议问题