【0】先看一段官方描述:
public class
SlidingDrawer
extends
ViewGroup
java.lang.Object |
↳ |
android.view.View |
|
↳ |
android.view.ViewGroup |
|
|
↳ |
android.widget.SlidingDrawer |
Class Overview
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:
- <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>
【1】简单的说就是:
SlidingDrawer是一个可以实现抽取式显示的控件,可以垂直,水平拉取,每个抽屉都包含两个东西:一个是拉手(handle),一个是抽屉里面的东西(content),SlidingDrawer需要放置在另外的一个layout之上,这意味着SlidingDrawer只能放置在 FrameLayout or a RelativeLayout里面。SlidingDrawer需要设置宽高为match_parent,而且在SlidingDrawer里面必须设置handle与content(显然,不然缺少任何一个都不叫“抽屉”啊)
【2】一些重要的属性与方法:
XML Attributes
<nobr><em>Attribute Name</em></nobr> |
<nobr><em>Related Method</em></nobr> |
<nobr><em>Description</em></nobr> |
android:allowSingleTap |
|
Indicates whether the drawer can be opened/closed by a single tap on the handle. 指示是否可以通过handle打开或关闭
|
android:animateOnClick |
|
Indicates whether the drawer should be opened/closed with an animation when the user clicks the handle. 指示是否当使用者按下手柄打开/关闭时是否该有一个动画
|
android:bottomOffset |
|
Extra offset for the handle at the bottom of the SlidingDrawer. |
android:content |
|
Identifier for the child that represents the drawer's content.指定抽屉的内容
|
android:handle |
|
Identifier for the child that represents the drawer's handle.指定把手handle
|
android:orientation |
|
Orientation of the SlidingDrawer.水平还是垂直
|
android:topOffset |
|
Extra offset for the handle at the top of the SlidingDrawer. |
Public Methods
<nobr>void</nobr> |
<nobr><span class="sympad"><span style="color:#ca0000">animateClose</span></span>()</nobr> Closes the drawer with an animation.关闭动画
|
<nobr>void</nobr> |
<nobr><span class="sympad"><span style="color:#ca0000">animateOpen</span></span>()</nobr> Opens the drawer with an animation.打开动画
|
<nobr>void</nobr> |
<nobr><span class="sympad"><span style="color:#ca0000">animateToggle</span></span>()</nobr> Toggles the drawer open and close with an animation.
|
<nobr>void</nobr> |
<nobr><span class="sympad"><span style="color:#ca0000">close</span></span>()</nobr> Closes the drawer immediately.
|
<nobr><span style="color:#ca0000">View</span></nobr> |
<nobr><span class="sympad"><span style="color:#ca0000">getContent</span></span>()</nobr> Returns the content of the drawer.获取抽屉的内容
|
<nobr><span style="color:#ca0000">View</span></nobr> |
<nobr><span class="sympad"><span style="color:#ca0000">getHandle</span></span>()</nobr> Returns the handle of the drawer.获取抽屉的把手
|
<nobr>boolean</nobr> |
<nobr><span class="sympad"><span style="color:#ca0000">isMoving</span></span>()</nobr> Indicates whether the drawer is scrolling or flinging.判断是否在移动
|
<nobr>boolean</nobr> |
<nobr><span class="sympad"><span style="color:#ca0000">isOpened</span></span>()</nobr> Indicates whether the drawer is currently fully opened.是否打开
|
<nobr>void</nobr> |
<nobr><span class="sympad"><span style="color:#ca0000">lock</span></span>()</nobr> Locks the SlidingDrawer so that touch events are ignores.锁死抽屉
|
<nobr>boolean</nobr> |
<nobr><span class="sympad"><span style="color:#ca0000">onInterceptTouchEvent</span></span>(<span style="color:#ca0000">MotionEvent</span>event)</nobr> Implement this method to intercept all touch screen motion events.
|
<nobr>boolean</nobr> |
<nobr><span class="sympad"><span style="color:#ca0000">onTouchEvent</span></span>(<span style="color:#ca0000">MotionEvent</span>event)</nobr> Implement this method to handle touch screen motion events.
|
<nobr>void</nobr> |
<nobr><span class="sympad"><span style="color:#ca0000">open</span></span>()</nobr> Opens the drawer immediately.打开抽屉
|
<nobr>void</nobr> |
<nobr><span class="sympad"><span style="color:#ca0000">setOnDrawerCloseListener</span></span>(<span style="color:#ca0000">SlidingDrawer.OnDrawerCloseListener</span>onDrawerCloseListener)</nobr> Sets the listener that receives a notification when the drawer becomes close.设置关闭抽屉监听
|
<nobr>void</nobr> |
<nobr><span class="sympad"><span style="color:#ca0000">setOnDrawerOpenListener</span></span>(<span style="color:#ca0000">SlidingDrawer.OnDrawerOpenListener</span>onDrawerOpenListener)</nobr> Sets the listener that receives a notification when the drawer becomes open.设置打开抽屉监听
|
<nobr>void</nobr> |
<nobr><span class="sympad"><span style="color:#ca0000">setOnDrawerScrollListener</span></span>(<span style="color:#ca0000">SlidingDrawer.OnDrawerScrollListener</span>onDrawerScrollListener)</nobr> Sets the listener that receives a notification when the drawer starts or ends a scroll.设置拉动抽屉监听
|
<nobr>void</nobr> |
<nobr><span class="sympad"><span style="color:#ca0000">toggle</span></span>()</nobr> Toggles the drawer open and close.切换打开和关闭的抽屉。
|
<nobr>void</nobr> |
<nobr><span class="sympad"><span style="color:#ca0000">unlock</span></span>()</nobr> Unlocks the SlidingDrawer so that touch events are processed.解锁
|
分享到:
相关推荐
Android Launcher抽屉类SlidingDrawer的使用
这是我自己编写的一个android 的slidingdrawer应用 效果还可以 希望可以帮助到刚刚学习android的朋友
这是一款不错的安卓SlidingDrawer抽屉控件案例,该案例的演示也很简单的,而且源码也很容易看得懂,非常适合一些新手的使用与学习,大家不妨去看看吧。
纯种的左侧或上侧抽屉-SlidingDrawer实现,这个问题困扰了我想当一段时间,看网上没有用SlidingDrawer实现左侧和上侧抽屉的(SlidingDrawer默认的是下侧和右侧,这个你懂的)。
Aj_01 来自:http://blog.csdn.net/Android_Tutor/archive/2010/04/14/5486804.aspx 测试:Android Launcher抽屉类SlidingDrawer的使用!
SlidingDrawer抽屉式滑动效果
这是一个SlidingDrawer抽屉控件的展示,抽屉里面的内容是一个gridview,gridview的内容是通过PackageManager读取手机安装的软件,适合初学者学习。
安卓中1.5后加入了SlidingDrawer【隐藏式抽屉】,设计原理在你的UI布局有限的情况下,放不下太多的控件的时候,可以考虑用这个隐藏式抽屉。用SlidingDrawer注意两点,一个是android:handle(委托要展开的图片加载...
实用的 Android SlidingDrawer抽屉效果
这是一款不错的安卓SlidingDrawer抽屉控件案例,该案例的演示也很简单的,而且源码也很容易看得懂,非常适合一些新手的使用与学习,大家不妨去看看吧。
这是一款不错的安卓SlidingDrawer抽屉控件案例,该案例的演示也很简单的,而且源码也很容易看得懂,非常适合一些新手的使用与学习,大家不妨去看看吧。
SlidingDrawer效果想必大家也见到过,它就是1.5模拟器上进入应用程序列表的效果。下面是截图 一、简介 SlidingDrawer隐藏屏外的内容,并允许用户通过handle以显示隐藏内容。它可以垂直或水平滑动,它有俩个View...
重写SlidingDrawer控件,实现向下混动的抽屉效果
默认显示抽屉的一部分,屏幕分上下二部分;通过打开按钮实现,抽屉的下面部分打开和关闭,同时上面部分自动伸展。
界面,实现一个layout或任何控件的向右拉出,向左收回效果。slidingdrawer的变形。在eclipse可直接运行。
Android SlidingDrawer控件的使用。开发环境Android studio3.0版本
本人最近发现了有趣的抽屉类,写了一个Demo与大家分享,希望能帮到大家!
SlidingDrawer隐式抽屉