"What is the difference between content_main xml and activity_main xml in
Android studio? "
The difference is actually just the name, and that content_main.xml, is usually used to load other elements using an include, by:
include layout="@layout/content_main
But it is simply a nomenclature which is not a restriction.
Both files can contain the elements you want to show in your UI and can be called as you wish. (keeping the restriction for resource naming), you can even create your own layout.
For example layout_principal.xml
, add elements and load it with setContentView()
to your Activity
and create another layout containing elements of the UI called contenido_principal.xml
, which would be loaded by <include>
.
In which of the two do I place the objects (TextView, Button, etc.)
of the design part? Because both .xml files have a design part
(Design)
You can place it directly inside the layout that loads your Activity by setContentView()
or if you want you can add them in another layout that would be for example content_main.xml
, and load this layout from the main layout by:
include layout="@layout/content_main
I recommend you read:
Reusing layouts with <include>