问题
I have a simple App, Layout XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<WebView
android:id="@+id/webview"
android:layout_width="200dp"
android:layout_height="200dp" />
</RelativeLayout>
When I use following code:
WebView webview = (WebView)findViewById(R.id.webview);
webview.getRootView().findViewById(android.R.id.content);
webview.getRootView().findViewById(android.R.id.content); return android.widget.FrameLayout.What is it? I never define FrameLayout in my app.Is that provided by Android by default?
回答1:
I think this question (although closed) answers it.
Difference between findViewById(R.id.content) and getRootView()
Check out the Hierarchy Viewer tool. If it very helpful for debugging your layouts. It will show you the entire tree of all the views in your Activity. At the root of almost every Activity is a FrameLayout I believe.
回答2:
FrameLayout is used internally by the WebView.
来源:https://stackoverflow.com/questions/12335578/what-is-android-widget-framelayout