Whenever any new project is being set up what we are seeing is only Activity_main.xml is being created under layout but no Content_main.xml is there
But whenever I am creating one, there are both xml files are being created i.e. Activity_main and Content_main.
What is the main reason for it? And what is the basic difference between these two?
Thanks in advance!
Why isn't there any Content_main.xml?
Post a Reply
|Oldest Newest Rating|
· January 14, 2016
Similar topic right here: https://www.thenewboston.com/forum/topic.php?id=11038
I did a little research and that's what I found:
Since the introduction of API level 23 they added things like the CoordinatorLayout, TabLayout, FloatingActionButton, etc. To simplify things they split the layout up into two files.
The activity_main is used to hold the layout, for example the TabLayout and the content_main is there to separate the actual content from the basic layout. This is only needed for the blank activity since this is using for example the FloatingActionButton.
When you have a look at the activity_main it includes the content_main. Two things you can do about it:
Just put all your layout stuff in the content_main and leave the activity_main alone or delete the content_main and delete the include statement from the activity_main and you're good to go (you might need to do some cleanup in the ActivityMain.java because it's referencing elements from the content_main there!)
Hope this helped
Java / Android Development
Very popular language used to create desktop applications, website applets, and Android apps.
|Bucky Roberts Administrator|