Reputation:
I am new in programming , I started learning java and worked with eclipse some time and know the very basics . Recently I started working with android studio and I have not used any other version except the 2.2.2 for very short period , and now the newest 2.2.3 . I am watching old tutorials and they work in activity_main , so my questions are :
1.In the newest version , should I work in the activity_main or in the content_main ?
Also I want to ask , if you can give me some new great pdf or tutorials to learn . Thanks .
Upvotes: 0
Views: 1156
Reputation: 178
I would suggest to get familiar with the different Android layouts (CoordinatorLayout
as in the activity_main
, LinearLayout
and so on). They define how you can arrange items within the layout, so whether there are some constraints on placing items depends on the layout.
There is no overall solution, whether someone should use content_main
and thus, nest layouts or just put everything into one file like e.g. activity_main
.
I personally use the nesting if I use a more complex layouts like an Activity
with a navigation drawer
. But for an app with one activity without additional navigation I would put everything into activity_main
.
For learning how to use the layouts one file might be easier instead of nesting.
Upvotes: 0
Reputation: 55
You should add code in the content_main XML file of your project. Content_main is actually the file containing the most of the UI of your MainActivity,except your navigation/toolbar. If at the beginning you are uncomfortable then instead of creating project with Blank activity, use Empty Activity shown in Figure
This will give you just only one activity_main XML file to work with. With time you will eventually understand the usage of Blank Activity as well.
Upvotes: 1