核心思想知识点:SlidingDrawer控件的使用
效果图如下
功能实现过程
1、styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="@android:style/Theme.NoTitleBar.Fullscreen">
</style>
</resources>
2、activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg"
>
<!--设置抽屉控件-->
<SlidingDrawer
android:id="@+id/drawer1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:content="@+id/myView"
android:handle="@+id/layout1"
android:orientation="horizontal">
<!--设置引导按钮-->
<LinearLayout
android:id="@id/layout1"
android:layout_width="35dp"
android:layout_height="match_parent"
android:gravity="center">
<ImageView
android:id="@+id/myImage1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/open" />
</LinearLayout>
<!--设置抽屉内容-->
<ImageView
android:id="@+id/myView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/iv_bg" />
</SlidingDrawer>
</RelativeLayout>
3、MainActivity.java
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}