3

I have recently updated android studio to 1.4 and noticed that there is now a content_main.xml and an activity_main.xml. It seems that content_main deals with what goes into the app and activity_main deals with the layout/display of the widgets from content_main, I am not sure whether this is correct? Also would it be possible for anyone to explain why having activity_main deal with just the layout is better and why Google decided to do this split?

All help is much appreciated.

Aniket Thakur
  • 66,731
  • 38
  • 279
  • 289
Hamid
  • 67
  • 2
  • 8
  • it is just a name convention. – Blackbelt Oct 17 '15 at 18:25
  • Possible duplicate of [What is the role of content\_main.xml in android studio 1.4?](http://stackoverflow.com/questions/32880722/what-is-the-role-of-content-main-xml-in-android-studio-1-4) – Zahan Safallwa Oct 17 '15 at 18:27
  • So what would happen if I deleted activity_main and just used content_main? – Hamid Oct 17 '15 at 18:27
  • @ZahanSafallwa I was just looking at a more in depth reason for the split. Don't understand why it was needed when activity_main used to handle everything. – Hamid Oct 17 '15 at 18:30
  • its just to bring flexibility in design nothing else. Design your tabhost etc layout on activity_main.xml and add widget to content_main.xml @Hamid – Zahan Safallwa Oct 17 '15 at 18:37

2 Answers2

2

I'll explain what they are for:

activity_main.xml:

this xml file is used to display coordinatorLayout,tabLayout,floatingActionButton,viewPager etc. 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

RITESH KUMAR
  • 1,070
  • 10
  • 10
0

It is just to keep the Palette separate form the activity_main.xml . All items are added to content_main and been included in activity_main