AndroidSlidingDrawer抽屉效果的实现
SlidingDrawer隐藏屏外的内容,并允许用户通过handle以显示隐藏内容。它可以垂直或水平滑动,它有俩个View组成,其一是可以拖动的handle,其二是隐藏内容的View.它里面的控件必须设置布局,在布局文件中必须指定handle和content。
1、布局layou文件
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world"/>
<SlidingDrawer
android:id="@+id/slidingdrawer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:content="@+id/content"
android:handle="@+id/handle"
android:orientation="vertical">
<Button
android:id="@+id/handle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SlidingDraser"/>
<LinearLayout<!--隐藏的内容-->
android:id="@+id/content"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#00ffaa">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"/>
<EditText
android:id="@+id/editText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</SlidingDrawer>
</LinearLayout>
2、下面是运行程序之后的界面
另:可在drawable中添加文件
<?xmlversion="1.0"encoding="utf-8"?>
<selectorxmlns:android="http://schemas.android.com/apk/res/android">
<itemandroid:state_window_focused="false"android:state_enabled="true"android:drawable="@drawable/handle_normal"/>
<itemandroid:state_pressed="true"android:drawable="@drawable/handle_pressed"/>
<itemandroid:state_focused="true"android:state_enabled="true"android:drawable="@drawable/handle_focused"/>
<itemandroid:state_enabled="true"android:drawable="@drawable/handle_normal"/>
<itemandroid:state_focused="true"android:drawable="@drawable/handle_focused"/>
</selector>
1、重要属性
android:allowSingleTap:指示是否可以通过handle打开或关闭
android:animateOnClick:指示是否当使用者按下手柄打开/关闭时是否该有一个动画。
android:content:隐藏的内容
android:handle:handle(手柄)
2、重要方法
setOnDrawerOpenListener
setOnDrawerScrollListener
相关文章
- css实现返回顶部,实现返回顶部效果
- (十四)51单片机——LCD1602实现滚动效果
- 链表和双向链表的实现
- Semaphore实现原理-共享锁
- WordPress 博客网站设置圣诞节雪花效果的实现方法
- Android自定义悬浮按钮效果实现,带移动效果详解手机开发
- python实现冒泡排序详解编程语言
- 使用jq实现简单的返回顶部效果详解编程语言
- Android利用DrawerLayout实现抽屉效果详解编程语言
- easyui formatter实现超链接效果详解编程语言
- Oracle表字段结构及其实现方法(oracle表字段)
- 实现异构系统:在虚拟机中安装Linux(在虚拟机装linux系统)
- 策略Java实现Redis过期策略(redisjava过期)
- 处理基于Redis和Java实现高效过期处理(redisjava过期)
- MySQL中函数递归:实现神奇的效果(mysql 函数递归函数)
- C语言与MySQL配合实现含参数插入(c mysql含参插入)
- MySQL两表累加简单实现数据求和(mysql两表累加)
- 横向扩展Redis,实现连接性能提升(横向扩展redis)
- 访问使用ABAP实现ORACLE数据库访问(ABAP实现ORACLE)
- MySQL实现获取上月日期的方法(mysql 上月日期)
- Oracle中2列求和的实现(oracle 2列求和)
- 科学家开发机器八目鳗 利用两个神经系统来实现更强大的性能
- 用asp实现的代码批量修改程序,fso相关
- CSSopacity-实现图片半透明效果的代码
- 几行代码轻松搞定jquery实现flash8类似的连接效果
- 通过隐藏option实现select的联动效果
- 新旧MFC版本实现CEdit透明的2种方法的实例代码
- python实现bitmap数据结构详解
- jQuery实现数字加减效果汇总
- PHP实现的多彩标签效果代码分享