Why do I use content_main.xml when I make it by applying material design?

Asked 2 years ago, Updated 2 years ago, 29 views

When you create a new project in the Android studio, If you select blank activity and create it, automatically

on the grid

compile 'com.Android.support:design:23.2.1 is added, and the layout of various support libraries, such as FAB, is automatically created, where main_activity.xml is

The content_main.xml file is automatically created. Is there a reason for this?

Do I have to make it like this to make it into a material design?

android

2022-09-22 21:54

1 Answers

I think it is for creating UI hierarchically rather than for material design. If you look at main_activity.xml, it looks like this.

<android.support.design.widget.CoordinatorLayout ...>
    <android.support.design.widget.AppBarLayout ...>
        <android.support.v7.widget.Toolbar .../>
    </android.support.design.widget.AppBarLayout>

    <include layout="@layout/content_main"/>

    <android.support.design.widget.FloatingActionButton .../>
</android.support.design.widget.CoordinatorLayout>

@layout/content_main is set to include and the Appbar layout, toolbar, floating action buttons are arranged above and below it. The content will change, but the layout of the appbar layout, toolbar, and floating action buttons seems to have been separated because similar arrangements may occur frequently.

Also, there will be additional advantages of not having to think about other factors when changing the content.


2022-09-22 21:54

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.