SlidingPaneLayout:在它的布局中有两个子控件,,第一个子控件作为侧滑菜单,可以从 左边滑出,第二个子控件为固定内容部分。
SlidingPanelLayout为在UI最上层的使用提供了一个水平的,多个面板的布局。左边的面板可以看作是一个内容列表或者是浏览,右边的面板的任务是显示详细的内容。
SlidingPaneLayout类也是直接继承于ViewGroup类,所以这个类也是当作容器类使用,在使用时通常可以和Fragement组件一起使用。下面这个利用就是利用ViewPager+Fragment+SlidingPaneLayout的简单运用。
主布局文件activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SlidingPaneLayout
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"
tools:context="com.example.slidingpanelayout.MainActivity">
<RelativeLayout
android:layout_width="250dp"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="这是侧滑菜单"
android:textSize="30sp"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RadioGroup
android:layout_width="match_parent"
android:layout_height="60dp"
android:id="@+id/rg"
android:orientation="horizontal"
android:layout_alignParentBottom="true">
<RadioButton
style="@style/bt"
android:text="Red"
android:checked="true"
android:id="@+id/red_bt" />
<RadioButton
style="@style/bt"
android:text="Green"
android:id="@+id/green_bt"/>
<RadioButton
style="@style/bt"
android:text="Blue"
android:id="@+id/blue_bt"/>
</RadioGroup>
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/rg"
android:id="@+id/frag_vp"/>
</RelativeLayout>
</android.support