一、抽屉效果
事例代码
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="45dip"
android:layout_centerInParent="true"
android:background="#8866ff00"
android:gravity="center"
android:text="流量统计"
android:textSize="25sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<View
android:layout_width="match_parent"
android:layout_height="100dip" />
<SlidingDrawer
android:id="@+id/sliding_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:content="@+id/mycontent"
android:handle="@+id/myhandle"
android:orientation="vertical" >
<LinearLayout
android:id="@id/myhandle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/lock" />
</LinearLayout>
<LinearLayout
android:id="@id/mycontent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#44000000"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="我是内容"
android:textSize="20sp" />
</LinearLayout>
</SlidingDrawer>
</LinearLayout>
</LinearLayout>
注:好好看看代码,水平抽屉和垂直抽屉都可实现
SlidingDrawer 已经过时了
setContentView(R.layout.activity_trafficmanager);
SlidingDrawer sd= (SlidingDrawer) findViewById(R.id.sliding_drawer);
sd.open();
来自为知笔记(Wiz)
时间: 2024-12-12 08:28:51