What is android.widget.FrameLayout

2019-08-12 23:31发布

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?

2条回答
Deceive 欺骗
2楼-- · 2019-08-13 00:13

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.

查看更多
时光不老,我们不散
3楼-- · 2019-08-13 00:15

FrameLayout is used internally by the WebView.

查看更多
登录 后发表回答