本文介绍了如何从使用setContentView设置的布局中获取根ViewGroup?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我似乎找不到找到该ViewGroup的方法.不确定是否有获取ViewGroups的标准方法.
I cannot seem to find a way to get this ViewGroup. Not sure if there are any standard ways to get ViewGroups.
我要完成的工作是在运行时向所有Layout动态添加全屏覆盖视图,为此,我始终需要获取根ViewGroup.这是正确的方法吗?
What I want to accomplish is to dynamically add a full screen overlay view to any Layout at run time, and in order to do this, I always need to get the root ViewGroup. Is this the right way to do this?
推荐答案
尝试使用
ViewGroup view = (ViewGroup) findViewById(android.R.id.content);
每个布局都将此ViewGroup作为父级.
Every layout has this ViewGroup as parent.
这篇关于如何从使用setContentView设置的布局中获取根ViewGroup?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!