SliderDraw 的關鍵是理解3點:
1:handle: 點擊的按鈕
2:content:展開的內容
3:SliderDraw不是一個獨立控件,而只能作爲2級控件來使用,即它外面必須再包一個view(layout)來控制大小,而它本身必須是充滿這個父view的。
主要工作在XML裏面:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src = "@drawable/backup"
/>
<RelativeLayout
android:layout_alignParentRight = "true"
android:layout_width="100dp"
android:layout_height="fill_parent"
>
<SlidingDrawer
android:id="@+id/drawer1"
android:layout_width = "wrap_content"
android:layout_height = "fill_parent"
android:handle = "@+id/myimage1"
android:content = "@+id/content1"
android:orientation="horizontal"
>
<ImageView
android:id="@id/myimage1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src = "@drawable/open"
/>
<GridView
android:id="@id/content1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numColumns="1"
android:background = "#80808080"
/>
</SlidingDrawer>
</RelativeLayout>
</RelativeLayout>