如何检查视图包含另一个视图?

Aru*_*tha 5 android view

有没有办法检查视图是否包含另一个特定视图?(indexOfChild仅适用于一级层次结构)

Dan*_*Vus 25

如果孩子没有id​​,请尝试这样的事情:

child.getParent() == parent
Run Code Online (Sandbox Code Playgroud)


Mic*_*ele 9

您可以使用findViewById()查找视图.喜欢:

yourview.findViewById(R.id.childView);
Run Code Online (Sandbox Code Playgroud)