Recipe Using the Hierarchy Viewer

A useful way to debug and understand the user interface is by using the Hierarchy Viewer. It provides a visual representation of the layout's View hierarchy (the Layout View) and a magnified inspector of the display (the Pixel Perfect View).

D/RILJ (

132)

I/GSM (

132)

delay=3

D/RILJ (

132)

D/RILJ (

132)

D/RILJ (

132)

D/RILJ (

132)

D/RILJ (

132)

D/RILJ (

132)

D/RILJ (

132)

D/RILJ (

132)

The Hierarchy Viewer is accessed using the tool hierarchyviewer. Executing this program launches the interface shown in Figure 12.6. It displays a list of Android devices that are currently connected to the development machine.When a device is selected, a list of running programs on the device is shown. It is then possible to select the program intended for debug or user interface optimization.

Figure 12.6 The Hierarchy Viewer tool.

After the program is selected, the Load View Hierarchy can be selected to see the View Tree constructed by the Hierarchy /Viewer. This is also called the Layout View. It contains three views:

■ Tree View—A hierarchy diagram of the views on the left.

■ Properties View—A list of the selected view's properties on the top, right.

■ Wire-frame View—A wire-frame drawing of the layout on the bottom, right.

This is shown in Figure 12.7.

These three views are related.When one node of the view is selected, the properties view and wire-frame view are updated. In an Android system, there is a limitation on the View Tree that each application can generate.The depth of the tree cannot be deeper than 10 and the width of the tree cannot be broader than 50. In Android 1.5 or earlier, there is stack overflow exception thrown when the view tree passes that limit. Although it is good to know the limitations, a shallow layout tree always makes the application run faster and smoother. This can be accomplished using merge or RelativeLayout instead of LinearLayout to optimize the View tree.

, Sr^p S^r^^f | ¿»frjfhWjndwi n.mtst | jQnd '-'M .. HitJirfhy~] | M 1.■ M > .v ; i'. v, . iMM | Lr^jl idj[* ftgqu»i UypL.

Umnllon Oiipjkfi ru I

, Sr^p S^r^^f | ¿»frjfhWjndwi n.mtst | jQnd '-'M .. HitJirfhy~] | M 1.■ M > .v ; i'. v, . iMM | Lr^jl idj[* ftgqu»i UypL.

Umnllon Oiipjkfi ru I

Figure 12.7 The Layout View in the Hierarchy View tool.
Character Building Thought Power

Character Building Thought Power

Character-Building Thought Power by Ralph Waldo Trine. Ralph draws a distinct line between bad and good habits. In this book, every effort is made by the writer to explain what comprises good habits and why every one needs it early in life. It draws the conclusion that habits nurtured in early life concretize into impulses in future for the good or bad of the subject.

Get My Free Ebook


Post a comment