Inspecting and Improving UI Layouts With HierarchyViewer
HierarchyViewer is a visual tool that can be used to inspect your Android user interfaces and help you improve your layout designs and performance. It’s packaged with the Android SDK, and lives in the <android-sdk>/tools folder.
To launch hierarchyviewer, simply open a terminal or command window and type hierarchyviewer. To open hierarchyviewer via Eclipse, select Window -> Open Perspective -> Hierarchy View.
For security reasons you can’t run it on-device, so you’ll need to have an application running on an emulator. Also, make sure Eclipse isn’t trying to debug your application when using HierarchyViewer or it won’t work.
As its name suggests, HierarchyViewer will present you with a hierarchy of the view objects for the layout you select. After you’ve launched the tool, select the Activity you’d like to profile and click the button labeled “Load View Hierarchy.” For my simple demo, the hierarchy looks like this:
In addition to providing information about the view hierarchy, the HierarchyViewer tool also provides 3 important metrics about the rendering performance for each View object on the selected Layout’s UI:
- The time it takes to Measure
- The time it takes to Layout
- The time it takes to Draw
Here’s a great Google IO presentation on using hierarchyviewer, and understanding these metrics:
About this entry
You’re currently reading “ Inspecting and Improving UI Layouts With HierarchyViewer ,” an entry on Public Static Droid Main
- 2.17.12 / 8pm