问题描述
在Android的的ViewGroup
从查看
继承。 A 的ViewGroup
是持有查看
。
In Android ViewGroup
inherits from View
. A ViewGroup
is a container which holds Views
.
ViewGroup (LinearLayout)
View (TextView)
为什么在Android的乡亲定义这种关系为继承
,而不是组成。由于的ViewGroup
包含查看
不是它应该是组成?
Why did folks at Android defined this relationship as Inheritance
instead of composition. As the ViewGroup
contains Views
shouldn't it be composition ?
推荐答案
我想你上了挂在措辞。
A的ViewGroup有每一点多少理由从查看继承为TextView的和ImageView的或...更重要的是......一个滚动型或SurfaceView (后两者都包含的东西)。
A "ViewGroup" has every bit as much reason to inherit from a "View" as a "TextView", and "ImageView" or ... more to the point ... a "ScrollView" or a "SurfaceView" (the latter two both "contain things").
或许,查看并不一定条件的最佳选择......但是类层次结构,使完整意义。不管是什么它的子类被命名为:)
Perhaps "View" wasn't necessarily the best choice of terms ... but the class heirarchy makes complete sense. Regardless of what it's subclasses are named :)
恕我直言...
这篇关于Android设备上查看和ViewGroup中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!