说到Android的UI就不得不从一切的开始View开始说。
让我们从Android Developer上的View的Overview和UI Overview来开始吧。
Class Overview
This 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.). The ViewGroup subclass is the base class for layouts, which are invisible containers that hold other Views (or other ViewGroups) and define their layout properties.
UI Overview
All user interface elements in an Android app are built using View and ViewGroup objects. A View is an object that draws something on the screen that the user can interact with. A ViewGroup is an object that holds other View (and ViewGroup) objects in order to define the layout of the interface.
Android provides a collection of both View and ViewGroup subclasses that offer you common input controls (such as buttons and text fields) and various layout models (such as a linear or relative layout).
通过这两段Overview,我们了解到View是UI的最基本组件,是所有控件布局的超类。它是一切开始的基本。
接着,该说到ViewGroup了。
java.lang.Object
---android.view.View
---android.view.ViewGroup
Class Overview
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.
ViewGroup继承自View,是一类特别的View,特别是因为他能包含其他View,是作为一种容器而存在。
下面要引用一张Android Developer上经典的老图了:
![](//img-blog.csdn.net/20130918142624875?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYWNpZHN3ZWV0/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
这张图说明View和ViewGroup是如何组合成一个完整的视图的,这里使用了一种叫做组合的设计模式。我们来看看这种设计模式在wiki上的定义:
组合模式:把多个对象组成树状结构来表示局部与整体,这样用户可以一样的对待单个对象和对象的组合。
View和ViewGroup就是基于这种设计模式的设计的,好处在于对ViewGroup来说它将它的子节点全都当成View而不关心它子节点到底是View还是ViewGroup。
View和ViewGroup组成了Android的UI的基石,UI设计也就是设计出一棵View树。
让我们从Android Developer上的View的Overview和UI Overview来开始吧。
Class Overview
This 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.). The ViewGroup subclass is the base class for layouts, which are invisible containers that hold other Views (or other ViewGroups) and define their layout properties.
UI Overview
All user interface elements in an Android app are built using View and ViewGroup objects. A View is an object that draws something on the screen that the user can interact with. A ViewGroup is an object that holds other View (and ViewGroup) objects in order to define the layout of the interface.
Android provides a collection of both View and ViewGroup subclasses that offer you common input controls (such as buttons and text fields) and various layout models (such as a linear or relative layout).
通过这两段Overview,我们了解到View是UI的最基本组件,是所有控件布局的超类。它是一切开始的基本。
接着,该说到ViewGroup了。
java.lang.Object
---android.view.View
---android.view.ViewGroup
Class Overview
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.
ViewGroup继承自View,是一类特别的View,特别是因为他能包含其他View,是作为一种容器而存在。
下面要引用一张Android Developer上经典的老图了:
这张图说明View和ViewGroup是如何组合成一个完整的视图的,这里使用了一种叫做组合的设计模式。我们来看看这种设计模式在wiki上的定义:
组合模式:把多个对象组成树状结构来表示局部与整体,这样用户可以一样的对待单个对象和对象的组合。
View和ViewGroup就是基于这种设计模式的设计的,好处在于对ViewGroup来说它将它的子节点全都当成View而不关心它子节点到底是View还是ViewGroup。
View和ViewGroup组成了Android的UI的基石,UI设计也就是设计出一棵View树。
---------------------------------------------------------------------------------------------------------------
如果文中有任何错误,欢迎指出。