I am new to Android App development. I have Android Studio 1.4. In my layout folder I have two XML files (content_main.xml
and activity_main.xml
). I have been following Bucky's tutorial and he just has the activity_main.xml
. Which one should I use?
The activity_main. xml is the "outer" part of the activity layout (toolbar, action button, etc.) and content_main. xml is the inner part where you put your own layout (the blank space).
The activity_main.xml is a layout file available in res/layout directory, that is referenced by your application when building its interface. You will modify this file very frequently to change the layout of your application.
According to new design pattern in android studio activity_main. xml will determine how the look of the main activity should be. And on the other hand content_main. xml will determine the contents in the activity_main.
Layout is where you organize the views in your page. But without activity, they have no meaning. Because in activity, you have to get these views and use them programmaticaly. All together, you load views from layout to activity and in activies you implement your whole program.
Unlike previous version, the new API 23 comes with the coordinatorLayout
and stuff and just to make them simple to use android has distinguished activity's layout into two different layout i.e. content_main.xml
& activity_main.xml
.
I'll explain what they are for:
activity_main.xml
this xml file is used to display coordinatorLayout
, tabLayout
, floatingActionButton
, viewPager
etc..
content_main.xml
This xml file is use to display your stuff i.e. what you want to display to users.
So, if you are just asking in which xml you have to put your stuff, content_main.xml
is the one....
I think the content_main.xml
is a part of activity_main.xml
. Because there is include layout="@layout/content_main"
in the activity_main.xml
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With