Android Apps 滑动式抽屉(SlidingDrawer)效果

button = (Button) findViewById(R.id.button);
handle = (Button) findViewById(R.id.handle);
handle1 = (Button) findViewById(R.id.handle1);
sd = (SlidingDrawer) findViewById(R.id.slidingdrawer);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
    sd.animateClose();
}
});
        
handle1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
    sd.animateOpen();
}
});

下午有两个布局,实现不同的效果

===========================================================================

<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="match_parent" android:background="@drawable/stephy">
<Button android:id="@+id/handle1" android:layout_width="100dp" android:background="#a5f871"
android:layout_height="30dp" android:text="CLICK"/>
    <SlidingDrawer android:id="@+id/slidingdrawer" android:layout_alignParentBottom="true"
    android:layout_width="fill_parent" android:layout_height="130dp"
    android:orientation="vertical" android:handle="@+id/handle"
    android:content="@+id/content" android:bottomOffset="0px">
    <Button android:id="@+id/handle" android:layout_width="100dp"    
    android:layout_height="30dp" android:background="#a5f871" android:text="DRAWER"/>
    <LinearLayout android:id="@+id/content"
    android:layout_width="fill_parent" android:layout_height="100dp" android:background="#dcf88e"
    android:gravity="center_vertical|center">
        <Button android:id="@+id/button" android:layout_width="wrap_content"
        android:layout_height="100dp" android:text="Button" android:background="#3356e7"/>
        <EditText android:id="@+id/editText" android:layout_width="fill_parent" android:layout_height="80dp"/>
    </LinearLayout>
</SlidingDrawer>
</RelativeLayout>

图片    图片


============================================================================


<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="match_parent" android:background="@drawable/stephy">
<Button android:id="@+id/handle1" android:layout_width="100dp" android:background="#a5f871"
android:layout_height="30dp" android:text="CLICK"/>
    <SlidingDrawer android:id="@+id/slidingdrawer" android:layout_alignParentBottom="true"
    android:layout_width="fill_parent" android:layout_height="130dp"
    android:orientation="vertical" android:handle="@+id/handle"
    android:content="@+id/content" android:bottomOffset="0px">
    <Button android:id="@+id/handle" android:layout_width="100dp"    
    android:layout_height="30dp" android:background="#a5f871" android:text="DRAWER"/>
    <LinearLayout android:id="@+id/content"
    android:layout_width="fill_parent" android:layout_height="100dp" android:background="#dcf88e"
    android:gravity="center_vertical|center">
        <Button android:id="@+id/button" android:layout_width="wrap_content"
        android:layout_height="100dp" android:text="Button" android:background="#3356e7"/>
        <EditText android:id="@+id/editText" android:layout_width="fill_parent" android:layout_height="80dp"/>
    </LinearLayout>
</SlidingDrawer>
</RelativeLayout>



 

图片          图片



备注:

SlidingDrawer的属性

android:allowSingleTap: 指示是否可通过单击handle打开或关闭(如果是false,刚用户必须通过拖动,滑动或者使用轨迹球,来打开/关闭抽屉。)默认的是true。

android:animateOnClick: 指示当用户点击handle的时候,抽屉是否以动画的形式打开或关闭。默认的是true。

animateClose():  Closes the drawer with an animation.

animateOpen():  Opens the drawer with an animation.


 

图片          图片



备注:

SlidingDrawer的属性

android:allowSingleTap: 指示是否可通过单击handle打开或关闭(如果是false,刚用户必须通过拖动,滑动或者使用轨迹球,来打开/关闭抽屉。)默认的是true。

android:animateOnClick: 指示当用户点击handle的时候,抽屉是否以动画的形式打开或关闭。默认的是true。

animateClose():  Closes the drawer with an animation.

animateOpen():  Opens the drawer with an animation.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

学英语的程序员

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值