zoukankan      html  css  js  c++  java
  • android提供ToolBar实现划动菜单的陷阱

    代码如下:

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
        <!--工具条-->
        <include layout="@layout/toolbar_main"></include>
    
        <android.support.v4.widget.DrawerLayout
            android:id="@+id/dl_AllLayout"
    
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true">
            <!--内容***************一定要放在滑动菜单的下方**************-->
            <include layout="@layout/content_main"/>
            <!--滑动菜单-->
            <include layout="@layout/layout_left_menu"></include>
        </android.support.v4.widget.DrawerLayout>
    </LinearLayout>

    众所周知,android系统在3.0之后的support-v7包中添加了ToolBar工具条和抽屉效果:

    import android.support.v7.app.ActionBarDrawerToggle;
    import android.support.v7.widget.Toolbar;

    那么在DrawerLayout中添加左滑菜单和主体内容时一定要注意优先添加,activity中的主要内容,后添加划动菜单布局。

    如果顺序相反会出现,在抽屉窗口中不能响应“点击”,“划动”等任何事件;而且在activity中将抽屉菜单滑动显示出来后,无法将其用手指滑动将其隐藏(可以通过ToolBar按钮隐藏)。

    因为DrawerLayout会最后去解析划动菜单,它认为DrawerLayout的最后一个儿子是滑动菜单

    请广大android盆友小心此问题!!!

  • 相关阅读:
    struts2的@Result annotation 如何添加params,并且在页面取值
    spring @Entity @Table
    @Results( 中 params 怎么用
    Java三种技术架构
    python 内存管理
    wxpyhon 鼠标事件例子
    常用wxPython事件描述
    wxpython 拖动界面时进入假死状态(未响应)解决方法
    python 的一些高级编程技巧
    python 访问器@property的使用方法
  • 原文地址:https://www.cnblogs.com/zzq-include/p/5596393.html
Copyright © 2011-2022 走看看