xml文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ff0000"
android:orientation="vertical" >
<SlidingDrawer
android:id="@+id/slidingdrawer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:content="@+id/content"
android:handle="@+id/handle"
android:orientation="horizontal" >
<ImageButton
android:id="@id/handle"
android:layout_width="50dip"
android:layout_height="44dip"
android:src="@drawable/ic_launcher" />
<LinearLayout
android:id="@id/content"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#00ff00" >
<TextView
android:id="@+id/tv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical|center_horizontal"
android:text="这是一个滑动式抽屉的示例"
android:textColor="#00ff00"
android:textSize="18px"
android:textStyle="bold" >
</TextView>
</LinearLayout>
</SlidingDrawer>
</LinearLayout>
以上有两个sildingdraw的属性需要注意一下; android:content="@+id/content"就是sildingdraw里面的内容
android:handle="@+id/handle"说句简单的就是一个打开sildingdraw的开关
实现sildingdraw也是比较简单的,主要就给sildingdraw设置一个开关的监听
/**
* 打开slidingdraw的事件
*/
slidingDrawer.setOnDrawerOpenListener(new OnDrawerOpenListener() {
@Override
public void onDrawerOpened() {
textView.setText("哈哈哈哈 我打开了");
}
});
关闭实现setOnDrawerOpenListener方法
下面是下载demo地址;http://download.csdn.net/detail/qq_30442585/9482871