实现Android 抽屉效果


在Android开发过程中,我们喜欢使用特效,比如抽屉效果,这样可以给人很好的体验。点击一个按钮,就像拉抽屉一样展开界面,这样的效果正是我在这里所要说明的。比如在AVD或真机上,我们都有看过这种效果。比较常用的应用是LAUNCH应用。在这个应用中我们实现了拉抽屉呈现所有的程序,在这里我参考一些别人写的博客试例讲这种实现细节。

创建一个工程。在这里我命名为LauncherDemo.在这个例子中我在main.xml文件中写入如下,贴上代码:

  1. <?xml version="1.0" encoding="utf-8"?>   
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:orientation="vertical"  
  4.     android:layout_width="fill_parent"  
  5.     android:layout_height="fill_parent"  
  6.     >   
  7. <SlidingDrawer   
  8.     android:id="@+id/slidingdrawer"  
  9.     android:layout_width="fill_parent"  
  10.     android:layout_height="fill_parent"  
  11.     android:orientation="vertical"  
  12.     android:handle="@+id/handle"  
  13.     android:content="@+id/content">   
  14.     <Button   
  15.         android:id="@+id/handle"  
  16.         android:layout_width="88dip"  
  17.         android:layout_height="44dip"  
  18.         android:background="@drawable/handle"  
  19.         />   
  20.     <LinearLayout   
  21.         android:id="@+id/content"  
  22.         android:layout_width="fill_parent"  
  23.         android:layout_height="fill_parent"  
  24.         android:background="#00ff00">   
  25.      
  26.            
  27.        <GridView   
  28.         android:id="@+id/allapps"  
  29.         android:layout_width="fill_parent"  
  30.         android:layout_height="wrap_content"  
  31.     />   
  32.     </LinearLayout>   
  33. </SlidingDrawer>   
  34. </LinearLayout>  
  • 1
  • 2
  • 下一页

相关内容