首页 > 其他 > 详细

DrawerLayout 使用

时间:2015-12-05 17:34:44      阅读:157      评论:0      收藏:0      [点我收藏+]
<?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);
}

 

DrawerLayout 使用

原文:http://www.cnblogs.com/freexiaoyu/p/5021850.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!