Create left Slide drawer
Step 1:
Dependent libraries:
Compile ' com.android.support:appcompat-v7:23.1.1' com.android.support:design:23.1.1 '
Step 2:
The main interface layout uses
Android.support.v4.widget.DrawerLayout
1<?xml version= "1.0" encoding= "Utf-8"?>2<android.support.v4.widget.drawerlayout xmlns:android= "Http://schemas.android.com/apk/res/android"3xmlns:app= "Http://schemas.android.com/apk/res-auto"4Android:id= "@+id/drawer"5Android:layout_width= "Match_parent"6android:layout_height= "Match_parent"7Android:fitssystemwindows= "true" >8 9<include layout= "@layout/content_main" ></include>Ten One A<Android.support.design.widget.NavigationView -Android:layout_width= "Match_parent" -android:layout_height= "Match_parent" theAndroid:layout_gravity= "Start" -Android:fitssystemwindows= "true" -app:headerlayout= "@layout/nav_header" -app:menu= "@menu/drawer_view" > + -</android.support.design.widget.NavigationView> +</android.support.v4.widget.DrawerLayout>
View Code
Step 3:
1. Set the head part layout in the left slide drawer, just a linearlayout plus a TextView
1<linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"2Android:layout_width= "Match_parent"3android:layout_height= "192DP"4Android:background= "? Attr/colorprimarydark"5Android:padding= "16DP"6Android:theme= "@style/themeoverlay.appcompat.dark"7android:orientation= "Vertical"8android:gravity= "Bottom" >9 Ten<TextView OneAndroid:layout_width= "Match_parent" Aandroid:layout_height= "Wrap_content" -android:text= "Username" -Android:textappearance= "@style/textappearance.appcompat.body1"/> the -</LinearLayout>
View Code
2. Set the menu layout in the left slide drawer (Note that this layout is written in the menu)
1<menu xmlns:android= "Http://schemas.android.com/apk/res/android" >2 3<group android:checkablebehavior= "single" >4<Item5Android:id= "@+id/nav_home"6android:icon= "@drawable/ic_dashboard"7android:title= "Home"/>8<Item9Android:id= "@+id/nav_messages"Tenandroid:icon= "@drawable/ic_event" Oneandroid:title= "Messages"/> A<Item -Android:id= "@+id/nav_friends" -android:icon= "@drawable/ic_headset" theandroid:title= "Friends"/> -<Item -Android:id= "@+id/nav_discussion" -android:icon= "@drawable/ic_forum" +android:title= "Discussion"/> -</group> + A<item android:title= "Sub items" > at<menu> -<Item -android:icon= "@drawable/ic_dashboard" -Android:title= "Sub Item 1"/> -<Item -android:icon= "@drawable/ic_forum" inAndroid:title= "Sub Item 2"/> -</menu> to</item> + -</menu>
View Code
Left Slide Drawer down!
Android Rapid Development _ build Materialdesign style framework