简体   繁体   English

具有资源ID的Android视图层次结构

[英]android view hierarchy with resource id

is there a way to get the hierarchy of the current layout of the device along with the resource id of the elements in the hierarchy? 有没有办法获取设备当前布局的层次结构以及层次结构中元素的资源ID?

I found a way to get the hierarchy but the IDs of the elements weren't there. 我找到了一种获取层次结构的方法,但是元素的ID不存在。

Also, note that i'm not doing that from inside the application with the current layout. 另外,请注意,我不是使用当前布局从应用程序内部执行此操作。

View has method: getParent() and getId(). 视图具有方法:getParent()和getId()。 ViewGroup hasMethod: getChildren(). ViewGroup hasMethod:getChildren()。 It is enough to get full hierarchy. 这足以获得完整的层次结构。 If you want to find out View hierarchy of elements in layout you should inflate this layout using LayoutInflater. 如果要查找布局中元素的“视图”层次结构,则应使用LayoutInflater对该布局进行充气。

Another solution is to create your own xml parser. 另一个解决方案是创建自己的xml解析器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM