今天记录一下抽屉式侧栏的实现
由于使用到了Android5.0的MD风格,所以要导入对应的依赖包(版本要对应support:appcompat的版本)。
compile ‘com.android.support:appcompat-v7:26.+’
compile ‘com.android.support:design:26.+’ //导入md风格依赖包
主要布局activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.android.example.navigationtest.MainActivity"
android:id="@+id/drawerlayout">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.suppo