大家可以把DrawerLayout 当成LinearLayout 等使用,主要注意两点:

1.添加布局 android.support.v4.widget.DrawerLayout 。
2.在DrawerLayout 下,设置底层布局和侧滑栏布局,同时设置侧滑栏效果android:layout_gravity,start 和end (left|right)即从左往右还是 从右往左出现。

<?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:id="@+id/drawer_layout"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:fitsSystemWindows="true"    tools:context=".MainActivity">   <LinearLayout       android:layout_width="match_parent"       android:layout_height="match_parent">       <Button           android:layout_width="wrap_content"           android:layout_height="wrap_content"           android:text="button"/>   LinearLayout>     <LinearLayout        android:layout_width="match_parent"        android:layout_height="match_parent"        android:background="@color/colorAccent"        android:fitsSystemWindows="true"        android:layout_gravity="start">LinearLayout>android.support.v4.widget.DrawerLayout>

通过以上xml文件,就可以实现DrawerLayout效果,再根据业务功能实现侧滑栏布局等。
PS:当侧滑栏没数据时,可能会出现卡顿,有数据以后就没问题了!!

更多相关文章

  1. Android Developers:在SQL数据库中保存数据
  2. Android页面跳转以及数据传递实现
  3. Android实现渐显按钮的左右滑动效果
  4. android编辑布局文件时非要降低api level或者更改主题才能显示布
  5. Android 线性布局:LinearLayout
  6. Android学习笔记-Android非布局activity中布局文件及控件加载方

随机推荐

  1. android ActionBar(官方指导)
  2. (原)Eclipse的java中文件读写
  3. ListView小知识整理:滑动背景、Item间隙等
  4. Android学习笔记6——基本布局
  5. ContentProvider详解
  6. android 录像/打开video文件
  7. Android曲线绘制demo
  8. Android 设备指纹
  9. Jenkins构建时’Users/Mac/Library/Andro
  10. Android: android source code online