有图有真相

下载地址:http://down.51cto.com/data/1417895

右侧的布局和左侧一致,关键在于android:layout_gravity="end"/"start"

xml如下:

<android.support.v4.widget.DrawerLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/drawer_layout"android:layout_width="match_parent"android:layout_height="match_parent"><!--页面视图--><FrameLayoutandroid:id="@+id/content_frame"android:layout_width="match_parent"android:layout_height="match_parent"/><!--左边滑出视图--><ListViewandroid:id="@+id/left_drawer"android:layout_width="240dp"android:layout_height="match_parent"android:layout_gravity="start"android:background="#111"android:choiceMode="singleChoice"android:divider="@android:color/transparent"android:dividerHeight="0dp"/><!--右边滑出视图end\start区分左右视图--><LinearLayoutandroid:id="@+id/right_drawer"android:layout_width="240dp"android:layout_height="match_parent"android:layout_gravity="end"android:background="#111"><TextViewandroid:layout_width="match_parent"android:layout_height="match_parent"android:text="anthoerpage"></TextView></LinearLayout></android.support.v4.widget.DrawerLayout>


视图的操作关键点:


mDrawerLayout.setDrawerShadow(R.drawable.ic_launcher,

Gravity.RIGHT);

mDrawerLayout.setDrawerListener(myDrawerListener);



mDrawerLayout.closeDrawer(Gravity.START); //关闭左边视图

mDrawerLayout.openDrawer(Gravity.START); //打开左边视图


此抽屉模式在陌陌聊天群里查看群成员里有,用户体验不错,很简单的实现

官方下载demo

http://developer.android.com/training/implementing-navigation/nav-drawer.html

csdn一篇翻译挺好的
http://blog.csdn.net/tu_bingbing/article/details/9008255


更多相关文章

  1. Android(安卓)CardView+RecyclerView实现卡片列表
  2. Android(安卓)pulltorefresh上拉下拉刷新加载
  3. Android(安卓)开发最佳实践
  4. Android(安卓)布局之GridLayout
  5. android之switch控件的用法
  6. android AppWidget的使用以及利用Service TimerTask实现widget的
  7. android 核心组件( 1 ) 常用布局, adapter, handler, UI
  8. android 完美的ListView实现【原创】
  9. android 多种特效TextView

随机推荐

  1. Android通过selector改变界面状态
  2. android的进度条使用
  3. Android(安卓)studio升级AndroidX
  4. About Android; Geocoder, “the service
  5. Android(安卓)- Android(安卓)Studio 自
  6. android工程下轻松运行java main程序
  7. android SharedPreferences 使用
  8. Android(安卓)Studio 默认debug证书位置
  9. 基于TCP/IP协议的Java服务端与Android客
  10. Android使用系统方法实现分享到QQ和微信!