安卓 DrawLayout侧滑

  

DrawerLayout顾名思义就是一个管理布局的。使用方式可以与其它的布局类类似。
DrawerLayout带有滑动的功能。只要按照drawerLayout的规定布局方式写完布局,就能有侧滑的效果。
直接将DrawerLayout作为根布局,然后其内部 

  第一个View为内容区域

  第二个View为左侧菜单   

第三个View为右侧侧滑菜单 

当前第三个是可选的。

注意这个属性android:layout_gravity="start"里面左中右分别放三个layout就可以了,简单的说在最外层套一个Drawerlayout,然后左中右分别可设置三个布局了,当然记得加上layout_gravity属性,同时中间布局是不可滑动的,左右两边可以,当然你也可以只设置一边

?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.administrator.layout.avitivty.tableActivity"
    >
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:background="@color/colorAccent"
    android:orientation="vertical"
   />
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"

        android:orientation="vertical"
        >
       <android.support.design.widget.TabLayout
           android:id="@+id/Tab_content"
           android:layout_height="0dp"
           android:layout_width="match_parent"
           android:layout_weight="1"
        />
    <android.support.v4.view.ViewPager
        android:id="@+id/pager_content"
        android:layout_height="0dp"
        android:layout_width="match_parent"
        android:layout_weight="8"
       />
</LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="right"
        android:background="@color/colorPrimaryDark"
        android:orientation="vertical"
        />
</android.support.v4.widget.DrawerLayout>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值