Random Posts

24/1/16

Part 4: The view hierarchy

The view hierarchy
Your widgets exist in a hierarchy of View objects called the view hierarchy. Figure 1.11 shows the view hierarchy that corresponds to the XMLin Listing 1.2.
Figure 1.11 Hierarchical layout of widgets and attributes


The root element of this layout’s view hierarchy is a LinearLayout. As the root element, the LinearLayout must specify the Android resource XMLnamespace at http://schemas.android.com/apk/res/android.
LinearLayout inherits from a subclass of View named ViewGroup. A ViewGroup is a widget that contains and arranges other widgets. You use a LinearLayout when you want widgets arranged in a single column or row. Other ViewGroup subclasses are FrameLayout, TableLayout, and RelativeLayoutWhen a widget is contained by a ViewGroup, that widget is said to be a child of the ViewGroup. The root LinearLayout has two children: a TextView and another LinearLayout. The child LinearLayout has two Button children of its own.

0 nhận xét:

Đăng nhận xét

Facebook