Skip to content

Most visited

Recently visited

navigation

Verify Your Design with Pixel Perfect

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

Figure 1. Android Device Monitor

  1. Connect your device to your computer. If prompted by a dialog on the device that asks, Allow USB debugging?, tap OK.
  2. Open your project in Android Studio, build and run it on your device.
  3. Select Tools > Android > 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.

  4. In the menu bar, select Window > Open Perspective, and then click Pixel Perfect.
  5. 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 View objects 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.

Figure 2. The Pixel Perfect 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.

This site uses cookies to store your preferences for site-specific language and display options.

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)