When creating new project, sometimes Android Studio creates activity_main.xml and content_main.xml, but sometimes it creates just activity_main.xml and not content_main.xml. I can't find the logic, under which condition it chooses which files to create. Can anyone explain it, please?
Asked
Active
Viewed 947 times
0
-
Possible duplicate of [Content\_main.xml missing](http://stackoverflow.com/questions/37268401/content-main-xml-missing) – sumandas Aug 22 '16 at 15:13
1 Answers
0
When you create a new activities, you can choose different options, two of them are Blank Activity (if I recall properly) and Empty Activity. The difference between them is that one is based in the modern Android approach, based on Fragments.
Therefore, activity_main.xml is simply the Activity layout containing a container (FrameLayout most probably) and content_main.xml is the layout for a Fragment put into this container somewhere within MainActivity.java.
Answer based on https://stackoverflow.com/a/33415349/6166978
-
I don't think content_main.xml is binded to any Fragments by default. It's just "included" into activity_main.xml – Asim Gasimzade Aug 22 '16 at 17:08
-
An activity that has no fragment doesn't need an content_main, so it only creates activity_main – Mese Aug 23 '16 at 09:29