一直想侧滑来着,今天终于开始了,。
先上几张截图:
1.首先要在project structure的dependence中导入v4.design包,导入后可以在build.grade下看到如下信息:
implementation 'com.android.support:design:26.1.0'
2.使用NavigationView
首先在主布局文件中使用DrawerLayout作为外包装,里面包含一个主页面和侧滑的菜单页面,而侧滑菜单页面用NavigationView实现:
上代码了:
activity布局:一个DrawerLayout+NavigationView
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawerlayout"
tools:openDrawer="start"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.desi