Changes

Jump to: navigation, search
no edit summary
Each view in a user interface represents a rectangular area of the display. A view is responsible for what is drawn in that rectangle and for responding to events that occur within that part of the screen (such as a touch event).
A user interface screen is comprised of a view hierarchy with a root view positioned at the top of the tree and child views positioned on branches below. The child of a container view appears on top of its parent view and is constrained to appear within the bounds of the parent view’s display area. Consider, for example, the user interface illustrated in Figure 1214-1:
[[Image:an_example_android_layout.png|An Android Studio user interface layout]]
Figure 1214-1
In addition to the visible button and checkbox views, the user interface actually includes a number of layout views that control how the visible views are positioned. Figure 1214-2 shows an alternative view of the user interface, this time highlighting the presence of the layout views in relation to the child views:
[[Image:android_view_layout_map_small.png|An Android User Interface Layout]]
Figure 1214-2
As was previously discussed, user interfaces are constructed in the form of a view hierarchy with a root view at the top. This being the case, we can also visualize the above user interface example in the form of the view tree illustrated in Figure 1214-3:
[[Image:android_view_hierarchy_diagram.png|The layout hierarchy of an Android user interface]]
Figure 1214-3
The view hierarchy diagram gives probably the clearest overview of the relationship between the various views that make up the user interface shown in Figure 1214-1. When a user interface is displayed to the user, the Android runtime walks the view hierarchy, starting at the root view and working down the tree as it renders each view.
== Creating User Interfaces ==

Navigation menu