I am new to Android Studio. Following the tutorial given by developer.android I have created a new project. They asked to create a blank activity and as there is no one such, I have used Empty Activity as the template. Then the tutorial said that there will be a content_main.xml inside res/layout folder, but I didn't find one. Did I build the correct Application? What probably may be the wrong? Thanks in advance.
-
Can you provide the link of the tutorial to your post? – AL. May 17 '16 at 06:14
-
Instead of using Empty Activity use Basic activity. It will create a basic template along with content_layout – Andan H M May 17 '16 at 06:15
-
Create new project with `Basic Activity` it will generate with `Content_main.xml`. – Jay Rathod May 17 '16 at 06:23
-
Check this out http://stackoverflow.com/questions/37049522/content-main-xml-is-not-generated-in-my-android-project/37049760#37049760 – Nongthonbam Tonthoi May 17 '16 at 06:35
-
https://developer.android.com/training/basics/firstapp/creating-project.html This is the link to that tutorial. Thanks @AndanHM, it worked. So if we create the application with basic_activity then it will have both the layout files. – aravindkanna May 17 '16 at 11:13
5 Answers
content_main.xml file will be generated when you choose "blank activity" . This activity will be having floating button by default at the bottom of the screen.
But when you choose "empty activty" then content_main.xml won't be generated and it won't be having floating button , but just simple activity.
So for your tutorial choose "blank activity" and then your tutorial will run fine

- 4,381
- 8
- 42
- 84
-
-
Is there any way to generate it manually or just we have to make a new project , i think it should have manual way to add and bind it with our activity – Sultan Ali Nov 14 '17 at 12:18
You need to select basic activity when creating a project. that will give you the 2 files content_main.xml and activity_main.xml

- 21
- 2
content_main.xml is used to handle the contents of the activity(like buttons, textView etc). So when we choose an empty activity, there are no components and hence the layout content file i.e. content_main.xml is not created. If you choose a blank activity there will be a floatingactionbutton component and hence there will be a content_main.xml created. So hopefully this will solve your problem. You can delete the floatingactionbutton later if you want your activity to be blank.

- 43
- 1
- 1
- 12
On the top right corner of the android studio code there is a search icon.
Click that and type: content_main.xml
You'll get the file over there open it.

- 1,460
- 11
- 19