1

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?

wayne_bai
  • 1,218
  • 4
  • 14
  • 23

2 Answers2

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.

Community
  • 1
  • 1
Jeff
  • 1,538
  • 2
  • 18
  • 33
  • 1
    *"At the root of almost every Activity is a FrameLayout I believe."* - Yup. I posted a few screenshots of a typical view hierachy/hierachyviewer in [this answer](http://stackoverflow.com/questions/9979648/activity-addcontentviewview-viewgroup-addcontentviewview/9979929#9979929). –  Sep 09 '12 at 01:53
  • Thanks Jeff and alextsc so much, appreciate your answer!Your answers are very helpful. – wayne_bai Sep 09 '12 at 02:31
-1

FrameLayout is used internally by the WebView.

Femi
  • 64,273
  • 8
  • 118
  • 148