通过Android Studio 生成的Nagvition DrawerLayout Activity 自带的布局中的NagvitionView会覆盖ToolBar直接通到statusBar。

但是自己想把NagvationView控制到TooBar下边,从网上找到的答案是把ToolBar从CoordinatorLayout里边移出来,然后

主布局文件:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimaryDark"
        />

    <android.support.v4.widget.DrawerLayout
        android:id="@+id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <include
            layout="@layout/app_bar_main"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

        <android.support.design.widget.NavigationView
            android:id="@+id/nav_view"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            app:menu="@menu/activity_main_drawer" />

    </android.support.v4.widget.DrawerLayout>

</LinearLayout>

这样就会可以了,但是发现Tool会产生异样的效果如:

其实是CoordinatorLayout的属性设置成了android:fitsSystemWindows="true",把这个属性去掉就好了。

app_bar_main布局:

 <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
      android:fitsSystemWindows="true"    <!--去掉这一句-->
     tools:context="com.mmmmar.box.MainActivity">

     <include layout="@layout/content_main" /><!--你自己的布局-->

     <android.support.design.widget.FloatingActionButton
         android:id="@+id/fab"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_gravity="bottom|end"
         android:layout_margin="@dimen/fab_margin"
         android:src="@android:drawable/ic_dialog_email" />

 </android.support.design.widget.CoordinatorLayout>

android ToolBar与DrawerLayout笔记的更多相关文章

  1. Android ToolBar自定义图标,关联DrawerLayout

    Android5.0出现了一个可以代替ActionBar的控件ToolBar,使用更加灵活,一般我们使用ToolBar来和DrawerLayout配合使用,官方提供了一个开关类ActionBarDra ...

  2. Android 之 ToolBar 踩坑笔记

    写在前面 •前言 这两天,学完了 Fragment 的基础知识,正准备跟着<第一行代码>学习制作一个简易版的新闻应用: 嘀嘀嘀~~~ 一声消息传来,像往常一样,打开 QQ,当我看到 QQ ...

  3. Android ToolBar

    众所周知,在使用ActionBar的时候,一堆的问题:这个文字能不能定制,位置能不能改变,图标的间距怎么控制神马的,由此暴露出了ActionBar设计的不灵活.为此官方提供了ToolBar,并且提供了 ...

  4. Toolbar和Drawerlayout的基本使用

    参考文章: http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2014/1118/2006.html http://www.codeceo.c ...

  5. .Net 转战 Android 4.4 日常笔记目录

    .Net 转战 Android 4.4 日常笔记(1)--工具及环境搭建 .Net 转战 Android 4.4 日常笔记(2)--HelloWorld入门程序 .Net 转战 Android 4.4 ...

  6. Android开发艺术探索笔记——View(二)

    Android开发艺术探索笔记--View(二) View的事件分发机制 学习资料: 1.Understanding Android Input Touch Events System Framewo ...

  7. Android开发艺术探索笔记—— View(一)

    Android开发艺术探索笔记 --View(一) View的基础知识 什么是View View是Android中所有控件的基类.是一种界面层控件的抽象. View的位置参数 参数名 获取方式 含义 ...

  8. Android 高级UI设计笔记07:RecyclerView 的详解

    1. 使用RecyclerView       在 Android 应用程序中列表是一个非常重要的控件,适用场合非常多,如新闻列表.应用列表.消息列表等等,但是从Android 一出生到现在并没有非常 ...

  9. 写一些有关android的东西吧,那时候玩android时候的一些笔记

    写一些有关android的东西吧,那时候玩android时候的一些笔记

随机推荐

  1. readline函数分析

    函数功能:提示用户输入命令,并读取命令/****************************************************************************/ /* ...

  2. block 数组排序

    #import <Foundation/Foundation.h> //定义⼀一个block,返回值为BOOL,有两个NSString参数.实现:判 //断字符串是否相等. BOOL (^ ...

  3. Unity问答——请问一下动画状态机怎么判断动画是否播完了?

    这篇博客源自我在泰课在线的回答.链接:http://www.taikr.com/group/1/thread/233 问:请问一下动画状态机怎么判断动画是否播完了? 答: 1. 脚本参考 Animat ...

  4. crf 分词(待)

    http://blog.csdn.net/marising/article/details/5769653

  5. BZOJ 1563 诗人小G

    Description Input Output 对于每组数据,若最小的不协调度不超过\(10^{18}\),则第一行一个数表示不协调度若最小的不协调度超过\(10^{18}\),则输出"\ ...

  6. SmartPhone手机网站的制作

    刚开始努力有点偏,看到响应式网站去了,其实主要是要用JQuery Mobile 做一个像应用的网站. JQuery Mobile的教程 http://www.hongkiat.com/blog/bui ...

  7. PCB板可靠性测试方法择要

    在电子设备中PCB板是所有电子设备的核心,其的可靠性程度会直接影响了产品的耐用性和寿命.因此在我们实验室(上海摩尔实验室)的实际工作中遇到了越来越多的针对PCB板的可靠性的测试要求,现根据一些企业的内 ...

  8. Content related to smartcards (and RFID/NFC)

    Introduction Add your content here. ISO/IEC 7816 Contact Cards Hardware EMV payment cards Orange Cas ...

  9. C# Linq-Aggregate

    The easiest to understand definition of Aggregate is that it performs an operation on each element o ...

  10. 【HDOJ】3451 Beat drop

    BFS.当水滴破裂飞溅后,直到碰到水滴才会停止(观察case1).同时,考虑当水滴飞溅到点(x,y)并且该点同一时间破裂的情况,该水滴算作吸收. /* 3451 */ #include <ios ...