如何获得android的当前布局?
问题描述:
答
尝试这些:
View currentView = this.getWindow().getDecorView().findViewById(android.R.id.content)
或
View currentView = this.findViewById(android.R.id.content)
或
View currentView = this.findViewById(android.R.id.content).getRootView()
或
如果你把一个ID,每个布局文件的根标签的象下面这样你可以得到的观点:
<RelativeLayout
android:id="@+id/rl_root_one"
,然后得到的观点:
RelativeLayout relativeLayout = (RelativeLayout)findViewById(R.id.rl_root_one);
使用上述方法中的任何一种都可以获得当前视图充气。
答
您可以使用此
this.getWindow().getDecorView().findViewById(android.R.id.content)
或本
this.findViewById(android.R.id.content).getRootView()
问题不清楚 – Krish