4

使用CoordinatorLayout在向下滚动时隐藏我的工具栏。“隐藏”工具栏在状态栏中可见

工具栏认为它已隐藏 - 但事实并非如此。

有没有人明白为什么会发生这种情况?

enter image description here

注:我的状态栏设置为半透明至有适当的材料抽屉。使状态栏变成纯色不是我正在寻找的解决方案 - 当然,除非这是如何打算使用的。

回答

1
+0

一直在寻找通过cheesesquare代码相当长一段时间;如果我将android:statusBarColor设置为透明,仍然有问题。使用折叠工具栏布局来隐藏工具栏可以隐藏工具栏,但如果我没有任何要使用的特征图像怎么办? –

2

我尝试设置状态栏的颜色作为primarydark,然后当抽屉被打开时,状态栏不能是透明的,否则工具栏会再次出来。 经过两天的工作,我发现如果我删除android:fitsSystemWindows="true"在我的CoordinatorLayout,它解决了。

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/drawer_layout" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fitsSystemWindows="true" 
tools:openDrawer="start"> 
<-- CoordinatorLayout is root of @layout/app_bar_home--> 
<include 
    layout="@layout/app_bar_home" 
    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" 
    android:fitsSystemWindows="true" 

    app:headerLayout="@layout/nav_header_home" 
    app:menu="@menu/activity_home_drawer" />