What is the difference between a View and widget in Android?

后端 未结 9 1764
轮回少年
轮回少年 2020-12-24 11:39

What is the difference between a View and widget in Android?

9条回答
  •  时光取名叫无心
    2020-12-24 12:20

    Lets come to the clear differences, without gigantic description..

    • A view is an object, can be put in layout or in pages. It is the basic building block for user interface components (you can refer these components as widget).
    • Widgets are small scale views(like button view, check box etc), that can be embedded in other views(like Home screen, login screen etc).

    Now you can think like , view is a container or place holder and widget is independent controls that you can place in any view.

    But keep in mind these are more like design concepts, not hardcore definitions.

    Finally, it can be concluded like,

    • An independent view, ready to use in any other views as an UI elements, can be referred as widget.

    For more explanation, have a look on basic code below:

    
       
          New jQuery UI Widget by souro
          
          
          
          
       
       
          

    Now you can see myButton is a small scale independent view i.e., widget and it is getting placed in a container button1 i.e, view, and yes you can put this widget in any other view i.e., purpose of widget. Make sense i guess.

提交回复
热议问题