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 ?
- In the activity_main the drag n drop function is not working , I can't move anything from palette to the screen to where i want (it goes directly in top left on the screen ). But in the content_main i can move once , and the second time the object puts itself in top left of the screen . How can i solve this and what is the problem ?
Also I want to ask , if you can give me some new great pdf or tutorials to learn . Thanks .
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.
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.