view-DrawerLayout 笔记

来源:互联网 发布:淘宝网点旺旺没反应 编辑:程序博客网 时间:2024/06/05 13:32

DrawerLayout

 

<android.support.v4.widget.DrawerLayout    xmlns:android="http://schemas.android.com/apk/res/android"    android:id="@+id/drawer_layout"    android:layout_width="match_parent"    android:layout_height="match_parent">
    <!-- 第一个是主界面内容,不一定是FrameLayout ,可以是任何布局-->    <FrameLayout        android:id="@+id/content_frame"        android:layout_width="match_parent"        android:layout_height="match_parent" />
    <!-- 第二个是侧滑界面,不一定是ListView,可以是任何布局-->    <ListView        android:id="@+id/left_drawer"        android:layout_width="240dp"        android:layout_height="match_parent"        android:layout_gravity="start"        android:choiceMode="singleChoice"        android:divider="@android:color/transparent"        android:dividerHeight="0dp"        android:background="#111"/></android.support.v4.widget.DrawerLayout>

 

1.DrawerLayout第一个子布局为主界面内容,第二个为侧滑界面内容

2.两个子布局可以为任意类型布局

3.监听为drawerlayout.addDrawerListener(DrawerLayout.DrawerListener())

4.DrawerLayout.closeDrawer方法用于隐藏侧边菜单,DrawerLayout.openDrawer方法用于展开侧边菜单

0 0
原创粉丝点击