Android之SlidingDrawer使用
slidingDrawer有垂直与水平的两种模式。最重要的还是在布局方面 : 在SlidingDrawer中handle与content的属性必须设置。
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
android:textSize="16sp"
/>
<SlidingDrawer
android:id="@+id/drawer1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:handle="@+id/layout1" //设置slidingdrawer拖动的图标
android:content="@+id/myContent1" //设置slidingdrawer的内容
android:orientation="horizontal" //设置slidingdrawer为水平模式
>
<LinearLayout
android:id="@id/layout1"
android:layout_width="35px" //由于slidingdrawer是水平模式,所以这里设置的width是从右边起
android:layout_height="fill_parent" //同理如果slidingdrawer是垂直模式,设置的height是从下面起
android:background="@drawable/black"
android:gravity="center"
>
<ImageView
android:id="@+id/myImage1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/open"
/>
</LinearLayout>
<GridView
android:id="@id/myContent1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numColumns="2"
android:background="@drawable/black"
android:gravity="center"
/>
</SlidingDrawer>
</RelativeLayout>