2017-04-04 61 views

回答

0

嘗試這些:

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); 

使用上述方法中的任何一種都可以獲得當前視圖充氣。

0

您可以使用此

this.getWindow().getDecorView().findViewById(android.R.id.content) 

或本

this.findViewById(android.R.id.content).getRootView() 
相關問題