2012-10-15 3 views
0

전체 화면으로 확장하려는 WebView가 있습니다. 사용자는 그것과 상호 작용할 것이므로 확장 될 때 어떤 종류의 상태를 유지해야합니다.Android보기 계층 구조 작동 방법

- Remove WebView from its parent 
- Put WebView at the top of the current View hierarchy with `FILL_PARENT` for width and height 

나중에 내가 다시 넣어 WebView를해야합니다 : 이상적인 프로세스는이이

- Remove WebView from top of the hierarchy 
- Restore the old hierarchy 
- Put WebView back where it was with its previous setting for width and height 

I에 대한 getRootView을 알고,하지만 나는 그것을 사용하는 방법을 모르겠어요. DecorView은 무엇입니까?

위에서 설명한 확장 및 축소 동작을 수행 할 수있는 샘플 코드가 있다면 누구나 감사하게 생각합니다. 감사!

View webViewParent = (View) webView.getParent(); 
webViewParent.removeView(webView); 

가에서 WebView을 넣어 :

parentViewGroup.removeViewAt(0); 

는 부모로부터 WebView을 제거

ViewGroup parentViewGroup = (ViewGroup) webView.getRootView().findViewById(android.R.id.content); 
View rootview = parentViewGroup.getChildAt(0); 

그 루트 뷰를 제거

답변

2

DecorView의 루트보기를 얻을 뷰 계층 구조의 최상위 :

parentViewGroup.addView(webView, 0, new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT)); 

rootview 참조를 사용하여 확장을 취소하십시오.

유일한 점은 : rootview의 레이아웃 매개 변수를 어떻게 복원 할 것인지 잘 모르겠습니다.