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盆友小心此问题!!!

  • 相关阅读:
    买二手房的税费详细版本
    实时推荐部分代码
    卡片推荐部分代码
    详解一下网络广告cpc、cpm、cpl、cpa、cps、cpr的计费方法是什么
    吴军硅谷来信《三板斧破四困境》
    JS实现的在线推荐逻辑
    mongo数据库时间存储的问题
    crontab 定时的陷阱
    【剑指offer】栈的压入、弹出序列
    【剑指offer】包含min函数的栈
  • 原文地址:https://www.cnblogs.com/zzq-include/p/5596393.html
Copyright © 2011-2022 走看看