How Do I Inspect The Layout Of An Alert Dialog Using Layout Inspector?
Solution 1:
I had the same issue. (I'm using Android Studio Arctic Fox 2020.3.1 patch 3)
Turned out the inspector by default filters out System-defined layers, and the dialog is one. There's this small button in the layout inspector, which looks like a filter.
Click it, disable the "Filter system defined layers" and another layer appears.
Before:
After:
Solution 2:
Using Android Studio Arctic Fox on Windows 10:
- Bring up the app with the dialog window showing in an emulator.
- Bring up the Layout Inspector View->Tools Window->Layout Inspector or you may have this in the lower right portion of the AS window
- You should see the Layout Inspector window pop up showing two DecorViews. (You may need to select the application.)
The top DecorView is the AlertDialog window. Click down through its hierarchy to see this:
From here you can see a visualization of the layout and the associated attributes:
In my experience, the Layout Inspector can be finicky at times. If the layout doesn't appear, try closing the Layout Inspector and restarting it.
Solution 3:
I wasn't able to get the alert dialog showing up in layout inspector, and had to use UI Automator Viewer
It's like Layout Inspector, but supports system and multi-app UIs, whereas Layout Inspector only supports single-app UIs. It feels like this UI is part of my app, but it's only showing up in UI Automator Viewer.
Post a Comment for "How Do I Inspect The Layout Of An Alert Dialog Using Layout Inspector?"