使用 ADB 时如何转储整个屏幕?

How can I dump the whole screen when using ADB?

我正在尝试使用 ADB 获取整个屏幕的层次结构。

如果我使用 adb shell uiautomator dump,我只能得到当前视图而不是整个屏幕。例如,如果我转储当前视图,然后向下滚动并再次转储,我将得到不同的输出。我想转储整个屏幕而不必向下滚动并再次转储。

if I am using the gmail app, in my inbox I have a list of emails that are currently in my view. Dumping will only give me that list of email, I want to know if there is a way of getting all emails in my inbox.

一般不会。

使用您的 Gmail 示例,假设 Gmail 应用程序在某个标签中显示对话,并且该标签包含 343,140,​​189 个对话。

(垃圾邮件,amirite?)

我猜您认为 Gmail 应用程序的 UI 有一个包含 343,140,​​189 行的滚动列表,而滚动只会改变这 343,140,​​189 行中的哪些行可见。

事实并非如此,原因有很多,例如应用 运行 内存不足。

Android 中的大多数滚动列表使用 类,例如 RecyclerViewListView。这些 类 回收了它们的行。因此,不是 343,140,​​189 行,而是少数,足以填满屏幕,也许还有几行。随着用户滚动,行从屏幕上滚落,它们被回收:填充新内容并作为 "new" 行输入。从视觉上看,效果与 343,140,​​189 行没有区别。从编程的角度来看,差异是显着的。从 uiautomator 的角度来看,编程才是最重要的。