Pixel Perfect is deprecated. Beginning with Android Studio 3.1, you should instead use Layout Inspector to compare your app layout with design mockups, display a magnified view of your app, and examine details of its layout.
Pixel Perfect is a tool built into Android Device Monitor that displays a magnified view of your app so you can inspect the position and properties of individual pixels in your layout, and help match your app's layout to design mockups.
Start Pixel Perfect
- Connect your device to your computer. If prompted by a dialog on the device that asks, Allow USB debugging?, tap OK.
- Open your project in Android Studio, build and run it on your device.
- Start Android Device Monitor.
Android Studio might show a Disable adb integration dialog because only
one process can connect to the device via adb at once, and Android Device
Monitor is requesting a connection. So click Yes.
Figure 1 illustrates what initially appears in the Android Device Monitor.
- In the menu bar, select Window > Open Perspective, and then click Pixel Perfect.
- Double-click the device name in the Windows tab on the left. This populates the panes with the device display and switches to the Pixel Perfect Tree tab.
Get familiar with the tools
You should see the following three panes:
- View Object (left): This is a hierarchical list of the
Viewobjects visible on the screen, including those owned by the system. When you click a view, its position is highlighted in the Pixel Perfect pane on the right.
- Pixel Perfect Loupe (center): This is the magnified screen image.
It's overlaid by a grid in which each square represents one pixel. To look at
the information for a pixel, click in its square. Its color information and X/Y
coordinates appear at the bottom of the pane.
The crosshair in the pane corresponds to the positioning crosshair in the Pixel Perfect pane (on the right).
To zoom, use the Zoom slider at the bottom of the pane, or use your mouse's scroll wheel.
- Pixel Perfect (right): This displays the device screen.
The crosshair in this pane corresponds to the crosshair in the Loupe pane.
The view selected in the View Object pane is also outlined here in bold red. Sibling and parent views have a light red box.
The layout box may have other rectangles either inside or outside it, each of which indicates part of the view. A purple or green rectangle indicates the view bounding box. A white or black box inside the layout box represents the view padding. An outer white or black rectangle represents the margins. The padding and margin boxes are white if the layout background is black, and vice versa.
You can save a screenshot by clicking Save as PNG at the top of the window.
By default, these panes do not refresh when the UI on the screen changes. To enable auto-refresh, enable Auto Refresh at the top of the window, and then set a refresh rate with the Refresh Rate slider at the bottom of the Loupe pane.
Otherwise, you can manually refresh the Pixel Perfect pane and the Loupe pane by clicking Refresh Screenshot at the top of the window. You also still might need to refresh the View Object pane by clicking Refresh Tree at the top of the window.
Add an overlay image
The Pixel Perfect window helps you match up your app layout to a mockup image by allowing you to load a bitmap as an overlay on the Pixel Perfect window.
To use a bitmap image as an overlay, follow these steps:
- At the top of Pixel Perfect, click Load Overlay and select your image.
- Pixel Perfect displays the overlay over the screen in the Pixel
Perfect pane. The lower left corner of the bitmap image (X=0, Y=max
value) is anchored on the lower left-most pixel (X=0, Y=max
screen) of the screen.
By default, the overlay has a 50% transparency. You can adjust this with the Overlay slider at the bottom of the Loupe pane.
Also by default, the overlay is not displayed in the Loupe pane. To display it, set Show in Loupe at the top of the window.
Content and code samples on this page are subject to the licenses described in the Content License. Java is a registered trademark of Oracle and/or its affiliates.