DrawLayout的简单使用
来源:互联网 发布:java分支语句行李 编辑:程序博客网 时间:2024/06/05 08:18
侧滑菜单的实现,本博客知道的就两种,slidingMenu和DrawLayout两种,这一篇为大家介绍一下android自带的侧滑菜单drawLayout,drawLayout使用起来非常方便,主要是xml布局中实现,下面是布局
drawLayout就是把要侧滑的布局全部放在
android.support.v4.widget.DrawerLayout的布局内,固定在中间的使用属性android:gravity="center"从左边侧滑的布局需要设置的属性是:android:layout_gravity="left"如果这些属性没有提示,不要认为错误,手动打出这些属性从右边侧滑的布局需要设置的属性是:android:layout_gravity="right"
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/dlMenu" android:layout_width="match_parent" android:layout_height="match_parent" tools:layout_editor_absoluteY="8dp" tools:layout_editor_absoluteX="8dp"> <LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:gravity="center_vertical" > <android.support.v4.view.ViewPager android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/vp_main" > </android.support.v4.view.ViewPager> <LinearLayout android:id="@+id/left_sliding" android:layout_gravity="left" android:layout_width="match_parent" android:layout_height="match_parent"> <FrameLayoutandroid:id="@+id/fl_left" android:layout_width="match_parent" android:layout_height="match_parent"> </FrameLayout> </LinearLayout> <LinearLayout android:id="@+id/right_sliding" android:layout_gravity="right" android:layout_width="match_parent" android:layout_height="match_parent"> <FrameLayout android:id="@+id/fl_right" android:layout_width="match_parent" android:layout_height="match_parent"> </FrameLayout> </LinearLayout> </android.support.v4.widget.DrawerLayout>在activity中的调用控件DrawLayout drawerLayout = (DrawerLayout) findViewById(R.id.dlMenu);最后为大家介绍常用的方法drawerLayout.openDrawer(ll_left);//打开左侧滑drawerLayout.openDrawer(ll_right);//打开右侧滑drawerLayout.closeDrawer(ll_left);//关闭左侧滑drawerLayout.closeDrawer(ll_right);//关闭右侧滑drawerLayout.closeDrawers();//关闭所有侧滑
判断是否打开drawerLayout.isDrawerOpen(ll_right);//判断右边是否打开drawerLayout.isDrawerOpen(ll_left);//判断左边是否打开//监听drawerLayout.addDrawerListener();这里面可以监听到侧滑的开始和结束还有侧滑时的状态介绍结束
阅读全文
0 0
- DrawLayout的简单使用
- DrawLayout的使用
- drawlayout的使用
- drawlayout的使用
- DrawLayout的使用
- DrawLayout的使用
- DrawLayout的使用
- ActionBar和Drawlayout的简单应用
- 王学岗ToolBar,DrawLayout+Navigation的使用(一)
- 王学岗ToolBar,DrawLayout+Navigation的使用(二)
- 王学岗ToolBar,DrawLayout+Navigation的使用(三)
- toolabar结合drawlayout使用
- 王学岗ToolBar,DrawLayout+Navigation的使用(四)——InputTextLayout
- DrawLayout
- DrawLayout
- Drawlayout
- DrawLayout
- drawlayout
- 算法的时间复杂度和空间复杂度-总结
- mysql的AUTO_INCREMENT如果达到最大值会怎样呢?
- hadoop
- Java实现选择与冒泡排序算法
- 练习Demo
- DrawLayout的简单使用
- 生而有涯而知也无涯
- [Hackerrank]hourrank 19-What Are the Odds?
- 图像超分辨率技术
- 指针建树
- 1、思考数据结构中逻辑结构、物理结构、操作运算三个方面的内容
- Crontab 设置定时抽取任务
- uva 10791
- [poj1204][caioj1465][AC自动机]地图匹配