Search code examples
androidandroid-linearlayoutparent-childandroid-framelayoutgravity

What is the parent layout of All Root layout in Android


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/linearLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
>

<TextView
    android:id="@+id/textView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/hello_world" 
    />
</LinearLayout> 

My Java Code:

linearLayout=(LinearLayout) findViewById(R.id.linearLayout);
System.out.println(linearLayout.getParent());

it will show you framelayout is the parent layout of linear layout.please tell 1. how frame layout is the parent layout of linear layout? 2. by Default window has frame layout?

Please help me.thanks in advance.


Solution

  • You're right, DecorView will use a FrameLayout to store all the content set by applications. You can read the source of PhoneWindow