zoukankan      html  css  js  c++  java
  • DrawerLayout 使用

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent" >
    
            <include
                android:id="@id/relative_top_title"
                layout="@layout/fragment_top_title" />
    
            <FrameLayout
                android:id="@id/frag_container"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_below="@id/relative_top_title" />
        </RelativeLayout>
    
        <LinearLayout
            android:id="@id/linear_leftmenu"
            android:layout_width="220.0dip"
            android:layout_height="match_parent"
            android:layout_gravity="left"
            android:background="@color/white"
            android:orientation="vertical" >
    
             <!--左侧菜单布局-->
        </LinearLayout>
    
        <LinearLayout
            android:id="@id/linear_rightmenu"
            android:layout_width="100.0dip"
            android:layout_height="match_parent"
            android:layout_gravity="right"
            android:background="@color/white"
            android:orientation="vertical" >
    
             <!--右侧菜单布局-->
        </LinearLayout>
    
    </android.support.v4.widget.DrawerLayout>

    android.support.v4.widget.DrawerLayout 做为根布局

    布局格式 一个第布局是内容,第二个是左侧菜单,第三个是右侧菜单,通过android:layout_gravity属性设置left和right来控件左右

    布局是固定好的

    因为我把左侧菜单和内容顺序搞返了 可以滑动打开但无法滑动关闭菜单中的所有事件点击没有任何反应,当时还以为要加什么属性调试很久,最后无意把布局换了下居然好了后来搜索后才知道这个问题

    //控制打开或关闭 这里是左侧

    if (mDrawerLayout.isDrawerOpen(Gravity.LEFT)) {
    mDrawerLayout.closeDrawer(Gravity.LEFT);
    } else {
    mDrawerLayout.openDrawer(Gravity.LEFT);
    }

  • 相关阅读:
    Linux下svn服务器搭建
    mybatis-generator自动生成代码插件使用详解
    java中Class.forName("xxx")和ClassLoader().loadClass("xxx")的区别
    ExecutorService中submit()和execute()的区别
    Redis学习总结(1)——数据持久化
    Java内存模型及性能优化
    (转)Lock和synchronized比较详解
    SpringBoot中获取spring.profiles.active
    SpringBoot添加拦截器
    SpringBoot与Kafka集成
  • 原文地址:https://www.cnblogs.com/freexiaoyu/p/5021850.html
Copyright © 2011-2022 走看看