android--利用SlidingPaneLayout实现简单的侧滑功能

         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
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值