Hierarchy Viewer

17
Debugging and Profiling UI Hierarchy Viewer

description

Hierarchy Viewer

Transcript of Hierarchy Viewer

Page 1: Hierarchy Viewer

Debugging and Profiling UI

Hierarchy Viewer

Page 2: Hierarchy Viewer

Layouts can slow down your appHow to Debug layout issues?

Problem

Page 3: Hierarchy Viewer

Android provides UI debugging tools:Hierarchy ViewerLayoutopt

Hierarchy Viewer allows:Debug and optimize UI

Provides:Visual view of Layout’s View hierarchy (View

Hierarchy window)Magnified view of display (Pixel Perfect

window)

UI debugging tools

Page 4: Hierarchy Viewer

launch an emulatorinstall the app you want to work withRun the app, and ensure that its UI is visible.From a terminal,

launch hierarchyviewer from the <sdk>/tools/ directory.

The first window you see displays a list of devices and emulators.

Steps:

Page 5: Hierarchy Viewer
Page 6: Hierarchy Viewer

Use it to look at View objects of Activity’s UITree View:

Examine individual View objectsRelationships between View objectsUse slider/mouse scroll wheel to zoomSearch by: “Filter by class or id” edit box

Nodes that match change from gray to bright blueSave tree screenshot: click Save As PNGSave as Photoshop (PSD) file: click Capture

LayersEach UI is saved as separate Photoshop layer

Hierarchy Window

Page 7: Hierarchy Viewer

Tree OverviewSmaller map represents entire Tree View windowUsed to identify part of view tree displayed on Tree

ViewProperties View

List of properties for selected View objectOrganized by category name

Layout ViewBlock representation of UIUsed to navigate the UI

Bold red: View that is currently selectedLight red: Parent block of selected ViewWhite: visible View not a parent/child of selected View

Hierarchy Viewer

Page 8: Hierarchy Viewer
Page 9: Hierarchy Viewer

Load View HierarchyView Hierarchy window is not automatically

updated when:UI of current Activity changesUser switches to new Activity

Used to load specific Activity View

Hierarchy Viewer

Page 10: Hierarchy Viewer

Individual Tree View Node:Information:

View class: View object’s classView object address: pointer to View objectView object ID: value of android:id attributeView index: zero-based index of View in its parent

ViewPerformance indicators: 3 colored dots

Show rendering speed of View relative to other View objectsGREEN: View is in faster 50% of all View objects in the treeYELLOW: Slower 50% of View objects in the treeRED: View is the slowest one in the tree

Hierarchy Window

Page 11: Hierarchy Viewer

When Node is selected, you get:Image: actual image of ViewView count: number of View objects Render times

Hierarchy Window

Page 12: Hierarchy Viewer
Page 13: Hierarchy Viewer

Tool used for :examining pixel properties and laying out UIs from a design drawing

To see Pixel Perfect Window:Start Hierarchy Viewer (above)click Inspect Screenshot

Pixel Perfect

Page 14: Hierarchy Viewer

Three Panes:View Object pane: shows hierarchical list of

View objectsPixel Perfect Loupe pane: holds a magnified

screen imPixel Perfect pane: displays the currently

visible screen as it appears on the Emulator

Pixel Perfect

Page 15: Hierarchy Viewer

To use a bitmap image as an overlay:Start your application in a device or emulator and navigate

to the Activity whose UI you want to work with.Start Hierarchy Viewer and navigate to the Pixel Perfect

window.At the top of the window, click Load Overlay. A dialog

opens, prompting for the image file to load. Load the image file.

Pixel Perfect displays the overlay over the screen image in the Pixel Perfect pane. The lower left corner of the bitmap image (X=0, Y=max value) is

anchored on the lower leftmost pixel (X=0, Y=max screen) of the screen.

By default, the overlay has a 50% transparency, which allows you to see the screen image underneath.

You can adjust this with the Overlay: slider at the bottom of the Loupe pane.

Pixel Perfect

Page 16: Hierarchy Viewer

Pixel Perfect Window