While setting the parameters for setContentView, which XML has to be
typed ? Content_main or Activity_main ?
You should use content_main.xml
to put your views but pass
activity_main.xml
as the parameter to you setContentView()
method.
activity_main.xml
is used to display coordinatorLayout, tabLayout, floatingActionButton, viewPager etc.
content_main.xml
is used to display your stuff i.e. what you want to display to users.
reference
And if I want to add an Layout file (XML) do I have to create 2 files
with the same name ?
Totally depends on the nature of the activity you are creating the layout for. The difference above will help you decide whether you need two or one.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…