Android SlidingDrawer 滑动抽屉效果


效果如下图,想必大家已经在很多应用中看到过了,下面来看看用SlidingDrawer 实现滑动抽屉效果

从Android1.5开始,加入了android.widget.SlidingDrawer类

SlidingDrawer控件的一些属性:

android:allowSingleTap指示是否可以通过handle打开或关闭
  android:animateOnClick 指示是否当使用者按下手柄打开/关闭时是否该有一个动画。
  android:content 隐藏的内容
  android:handle handle

布局文件:

  1. <LinearLayout   
  2.     xmlns:android="http://schemas.android.com/apk/res/android" 
  3.     android:layout_width="match_parent" 
  4.     android:layout_height="match_parent"   
  5.     android:orientation="vertical" 
  6.     android:background="@drawable/f"> 
  7.     <TextView 
  8.         android:layout_width="match_parent" 
  9.         android:layout_height="wrap_content" 
  10.         android:gravity="center_vertical|center_horizontal"/> 
  11.     <SlidingDrawer 
  12.         android:id="@+id/slidingdrawer" 
  13.         android:layout_width="match_parent" 
  14.         android:layout_height="wrap_content" 
  15.         android:content="@+id/content" 
  16.         android:handle="@+id/handle" 
  17.         android:orientation="vertical" > 
  18.         <ImageView 
  19.             android:id="@id/handle" 
  20.             android:layout_width="wrap_content" 
  21.             android:layout_height="wrap_content" 
  22.             android:src="@drawable/music_list_btn" > 
  23.         </ImageView> 
  24.         <LinearLayout 
  25.             android:id="@id/content" 
  26.             android:layout_width="match_parent" 
  27.             android:layout_height="match_parent" 
  28.             android:background="@drawable/t"> 
  29.             <TextView 
  30.                 android:layout_width="match_parent" 
  31.                 android:layout_height="match_parent" 
  32.                 android:text="隐藏的内容"/> 
  33.         </LinearLayout> 
  34.     </SlidingDrawer> 
  35. </LinearLayout> 
  • 1
  • 2
  • 下一页

相关内容