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方法用于展开侧边菜单
本文介绍如何使用DrawerLayout实现Android应用的侧滑菜单功能。主要内容包括DrawerLayout的基本结构、子布局的定义方式及其尺寸设定,同时提供了打开和关闭侧边菜单的方法。
6125

被折叠的 条评论
为什么被折叠?



