如何使用布局检查器检查警报对话框的布局? [英] How do I inspect the layout of an Alert Dialog using Layout Inspector?

查看:34
本文介绍了如何使用布局检查器检查警报对话框的布局?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图了解 AlertDialog 中元素的间距.AlertDialog 是使用 AlertDialog.Builder 创建的,并包含一个自定义 ListView(通过 setView 设置).

I am trying to understand the spacing of elements in an AlertDialog. The AlertDialog is created using AlertDialog.Builder and contains a custom ListView (set via setView).

在我的设备上(通过 USB)调试应用程序时,我可以在 android studio 中启动布局检查器并观察/研究当前布局.当我启动对话框时,它出现在屏幕和布局检查器中,但我似乎无法点击它或查看它的布局.组件树中仅显示启动对话框的主应用程序的布局.

When the app is being debugged on my device (over USB) I can launch the Layout Inspector in android studio and observe / study the current layout. When I launch the dialog, it appears on screen and in the layout inspector, but I cannot seem to click on it or view it's layout. Only the layout of the main app, from which the dialog was launched, is visible in the Component Tree.

FWIW,我试图使用布局检查器解决的直接问题是减少警报对话框中消息文本和我的视图之间的间距.

FWIW, the immediate issue I am trying to solve using layout inspector is reducing the spacing between the message text, and my View, in the alert dialog.

推荐答案

我无法在布局检查器中显示警报对话框,不得不使用 UI 自动查看器

I wasn't able to get the alert dialog showing up in layout inspector, and had to use UI Automator Viewer

它类似于布局检查器,但支持系统和多应用界面,而布局检查器仅支持单应用界面.感觉这个 UI 是我应用的一部分,但它只显示在 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.

这篇关于如何使用布局检查器检查警报对话框的布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆