本文由PurpleSword(jzj1993)原创,转载请注明
原文网址 http://blog.csdn.net/jzj1993
Layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<SlidingDrawer
android:id="@+id/slidingdrawer"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/buttons_container"
android:layout_below="@+id/bn_repeat"
android:layout_centerHorizontal="true"
android:content="@+id/content"
android:handle="@+id/handle"
android:orientation="horizontal" >
<ImageView
android:id="@+id/handle"
android:layout_width="45dip"
android:layout_height="80dip"
android:scaleType="fitXY"
android:src="@drawable/ic_handle" />
<LinearLayout
android:id="@+id/content"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#F0F0F0" >
<ListView
android:id="@+id/drawer_list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</SlidingDrawer>
</RelativeLayout>
Java程序
SlidingDrawer drawer;
drawer = (SlidingDrawer) this.findViewById(R.id.slidingdrawer);
drawer.setOnDrawerOpenListener(onDrawerOpenListener);
drawer.setOnDrawerCloseListener(onDrawerCloseListener);
private OnDrawerOpenListener onDrawerOpenListener = new OnDrawerOpenListener() {
@Override
public void onDrawerOpened() {
drawerOpened = true;
refreshVoiceButton();
}
};
private OnDrawerCloseListener onDrawerCloseListener = new OnDrawerCloseListener() {
@Override
public void onDrawerClosed() {
drawerOpened = false;
refreshVoiceButton();
}
};