滑动式抽屉_SlidingDrawer

http://developer.android.com/reference/android/widget/SlidingDrawer.html

应用场景:从下边或者右边拖出或弹出一个控件,提供操作快捷方式;

问题:滑动抽屉由什么组成?把手和隐藏控件;handle and content

思考:1.抽屉的把手用什么做?drag a handle to bring the content on screen

            2.隐藏控件用什么做?SlidingDrawer hides content out of the screen

            3.滑动抽屉有什么监听器?

      总之都是view对象,handle可以用ImageView来做,也可用TextView来做,毕竟它们都是view的子类;

       content也一样,可以装一个GridView 也可以是一个ListView,也可以是一个LinearLayout,其中有多个View对象;

       监听器:滑动时 OnDrawerScrollListener

                       打开时 OnDrawerOpenListener

                       关闭时 OnDrawerCloseListener


接口简介:

interface SlidingDrawer.OnDrawerCloseListenerCallback invoked when the drawer is closed. 
interface SlidingDrawer.OnDrawerOpenListenerCallback invoked when the drawer is opened. 
interface SlidingDrawer.OnDrawerScrollListenerCallback invoked when the drawer is scrolled. 


类的简介:

SlidingDrawer hides content out of the screen and allows the user to drag a handle to bring the content on screen. SlidingDrawer can be used vertically or horizontally. A special widget composed of two children views: the handle, that the users drags, and the content, attached to the handle and dragged with it. SlidingDrawer should be used as an overlay inside layouts. This means SlidingDrawer should only be used inside of a FrameLayout or a RelativeLayout for instance. The size of the SlidingDrawer defines how much space the content will occupy once slid out so SlidingDrawer should usually use match_parent for both its dimensions. Inside an XML layout, SlidingDrawer must define the id of the handle and of the content:


操作步骤:

     1.在布局文件中,配置对象,该对象应该放在FrameLayout或RelativeLayout中;

 <SlidingDrawer
     android:id="@+id/drawer"
     android:layout_width="match_parent"
     android:layout_height="match_parent"

     android:handle="@+id/handle"
     android:content="@+id/content">

     <ImageView
         android:id="@id/handle"
         android:layout_width="88dip"
         android:layout_height="44dip" />

     <GridView
         android:id="@id/content"
         android:layout_width="match_parent"
         android:layout_height="match_parent" />

 </SlidingDrawer>
       2.在程序代码中,设置监听,获取控件,设置监听;






评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值