Tablayout
switching between different views via tab in the app is not a new concept for material design, they are equivalent to the top navigation mode of the home page or the content of different groups within the app , .
The tablayout provides both a fixed tab-average width distribution of the view and a scrollable tab-the view width is not fixed and can be scrolled horizontally.
tabs can be added dynamically in your program:
tablayout tablayout = (tablayout) Findviewbyid (r.id.tabs);
Tablayout.addtab (Tablayout.newtab (). SetText (TAB1)); Tablayout.addtab (Tablayout.newtab (). SetText (TAB2)); Tablayout.addtab (Tablayout.newtab (). SetText (TAB3));
But most of the time we will not use this, usually the sliding layout will be used in conjunction with Viewpager, so we need Viewpager to help:
Mviewpager = (Viewpager) Findviewbyid (R.id.viewpager);
Set Viewpager data, etc.
Setupviewpager ();
Tablayout tablayout = (tablayout) Findviewbyid (r.id.tabs);
Tablayout.setupwithviewpager (Mviewpager);
By a word setupwithviewpager, we put Viewpager and tablayout together.
Navigationview
Navigationview is very important in MD design, before Google also proposed using Drawerlayout to implement the navigation drawer. This time, in the support library, Google provided navigationview to implement the navigation menu interface .
The most important of these are the two properties:
App:headerlayout
App:menu
with these two properties, we can easily specify the head layout and menu layout of the navigation interface:
<android.support.v4.widget.drawerlayout
http:// Schemas.android.com/apk/res/android
xmlns:app= ' Http://schemas.android.com/apk/res-auto '
Android:layout_width= ' Match_parent '
android:layout_height= ' Match_parent '
Android:fitssystemwindows= ' true ' >
<!--your content layout--
<android.support.design.widget.navigationview
Android:layout_width= ' Wrap_content '
android:layout_height= ' Match_parent '
Android:layout_gravity= ' Start '
app:headerlayout= ' @layout/drawer_header '
app:menu= ' @menu/drawer '/>
</android.support.v4.widget.DrawerLayout>
From for notes (Wiz)
Android? M. Controls: Toolbar, Tablayout, Navigationview