I have a very trivial confusion regarding the what is the root view of an activity. I searched this throughout google and stack overflow. I got some knowledge about it but didn't come to a convincing solution as no one clearly said about that term. The question which seems to be alike my question tell about what a root view of a given layout is but to me they don't seem to specify the root view of an activity is.Though the answer to my question is quite intuitive, I want a definite answer with no confusion.So here is the code structure. I have the following activity class :
package com.example.android.viewpager;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
And the XML code associated with it when I created the activity is (activity_main.xml) :
<LinearLayout 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"
android:orientation="vertical"
tools:context="com.example.android.viewpager.MainActivity">
</LinearLayout>
So according to me is this activity_main.xml
the root view of the MainActivity
?
The Root View of Your MainActivity
is LinearLayout
The Root View
of Your Activity means the Top most parent layout of Your XML
Layout
The Root View may be a
RelativeLayout
,CoordinatorLayout
,ConstraintLayout
,LinearLayout
,FrameLayout
For Example
Your activity_main.xml
Contain LinearLayout
as parent layout than LinearLayout
is your Root View which hold all the child controlls in it like Buttons
, Imageview
, EditText
, TextView
, etc....