android中侧滑栏的实现

1:drawerlayout类作为父控件 出现在最顶层。

2:被包裹的二级布局就可以是 侧滑栏或者是页面本身。

3:只要是在耳机布局的gravaty——layout属性声明一个start属性,即可实现策侧滑效果。

下面贴代码:

<android.support.v4.widget.DrawerLayout
    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">


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/gray_background"
        android:fitsSystemWindows="false"
        android:orientation="vertical"
        tools:context="com.safe.peoplesafety.Function.home.HomeActivity">


        <android.support.v4.view.ViewPager
            android:id="@+id/home_vp"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1" />

        <RadioGroup
            android:id="@+id/home_rg"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:background="#ffffff"
            android:orientation="horizontal">

            <RadioButton
                android:id="@+id/home_rg_1st_rb"
                style="@style/style_home_activity_bottom_rb"
                android:drawableTop="@drawable/home_tab_1st_icon"
                android:text="@string/home_page_1st" />

            <RadioButton
                android:id="@+id/home_rg_2nd_rb"
                style="@style/style_home_activity_bottom_rb"
                android:drawableTop="@drawable/home_tab_2nd_icon"
                android:text="@string/home_page_2nd" />

            <RadioButton
                android:id="@+id/home_rg_3rd_rb"
                style="@style/style_home_activity_bottom_rb"
                android:drawableTop="@drawable/home_tab_3rd_icon"
                android:text="@string/home_page_3rd" />
        </RadioGroup>
    </LinearLayout>

    <include layout="@layout/fragment_home_left_item"/>

</android.support.v4.widget.DrawerLayout>
倒数第二行就是侧滑菜单,点进去是这样的
 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="280dp"
    android:layout_gravity="start"
    android:background="@color/white"
    android:layout_height="match_parent">
可以看到的是layout_gravity属性是start。这儿决定了这个菜单是个侧滑菜单。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值