Skip to content

Most visited

Recently visited


Debug Your Layout with Layout Inspector

The Layout Inspector in Android Studio allows you to inspect your app's view hierarchy at runtime from within the Android Studio IDE. This is particularly useful when your layout is built at runtime rather than entirely in XML and the layout is behaving unexpectedly.

Open the Layout Inspector as follows:

  1. Run your app on a connected device or emulator.
  2. Click Tools > Android > Layout Inspector.
  3. In the Choose Process dialog that appears, select the app process you want to inspect and click OK.

    Figure 1. The Choose Process dialog

    By default, the Choose Process dialog lists only the process for the project currently opened in Android Studio—and it must be running on the device. If you want to inspect a different app that's on the device, check Show all processes. If you're using a rooted device or an emulator without Google Play store, then you'll see all running apps. Otherwise, you'll see only running apps that are debuggable.

The Layout Inspector captures a snapshot, saves it as a .li file, and opens it. As shown in figure 2, the Layout Inspector displays the following:

  1. View Tree: The hierarchy of views in the layout.
  2. Screenshot: The device screenshot with visible boundaries for each view.
  3. Properties Table: The layout properties for the selected view.

Figure 2. The Layout Inspector

You can click a view in the View Tree to select the same view in the screenshot, and vice versa. All the layout attributes for the view appear in the Properties Table.

If your layout includes overlapping views, then by default, only the view in front is clickable in the screenshot. To make the view behind clickable in the screenshot: Right-click the in-front view in the View Tree and uncheck Show in preview. It doesn't make the view content disappear; it only makes the clickable boundaries in the screenshot disappear so that you can instead click the views behind it.

If the layout on the device changes, the Layout Inspector does not update. You must create a new snapshot by again clicking Tools > Android > Layout Inspector. Each snapshot is saved in a separate .li file in project-name/captures/.

Figure 3. Layout Inspector snapshots (.li files) in the Project window

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

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields


在 WeChat 上追蹤 Google Developers

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. (Dec 2017 Android Platform & Tools Survey)