Android 工具栏没有完全隐藏(> Lollipop)

标签 android android-actionbar android-support-library android-toolbar

在我的应用程序中,我使用 AppBarLayoutToolbar 作为我的支持操作栏。我希望它在用户滚动内容时隐藏/显示。在 KitKat 上一切正常,但在 Lollipop 和 Marshmallow 上工具栏没有滚动到它的全高。 Screen with toolbar fully scrolled

我的布局:

<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"
    android:fitsSystemWindows="true"
    tools:context="(...)">

    <include
        android:id="@+id/app__content"
        layout="@layout/app_bar__main"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <fragment android:id="@+id/navigation_drawer"
        android:layout_width="@dimen/navigation_drawer_width"
        android:layout_height="match_parent"
        android:layout_gravity="left"
        android:fitsSystemWindows="true"
        android:name="(...)"
        tools:layout="@layout/fragment__navigation_drawer" />

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

app_bar__main.xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="(...)">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/app__appbarlayout__action_bar_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/app__toolbar"
            android:layout_width="match_parent"
            android:layout_height="@dimen/action_bar__height"
            android:background="@drawable/toolbar__background"
            android:elevation="4dp"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/AppTheme.PopupOverlay"
            tools:ignore="UnusedAttribute" />

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

    <include layout="@layout/app_content__main" />

    <include android:id="@+id/app__layout__bottom_bar"
        layout="@layout/layout__bottom_bar" />

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

app_content__main.xml 只是我要向其中添加 fragment 的 FrameLayout。我使用 support:appcompat-v7:23.3.0support:design:23.2.0(由于工具栏的另一个错误,无法使用 23.3.0)。它在 23.0.0 上工作,但有什么方法可以让我在不移动到这个以前的版本的情况下工作吗?

最佳答案

您必须从 CoordinatorLayout 中删除 android:fitsSystemWindows="true"。

关于Android 工具栏没有完全隐藏(> Lollipop),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36918203/

相关文章:

Android Activity 生命周期 - 通知服务

android:showAsAction ="always"不适用于选项卡 fragment

android - getActionBar().setDisplayHomeAsUpEnabled(true); preferenceActivity 中的空指针

android - 方法 setTabListener 不适用

java - 使用 charAt() 查找空格、换行符和制表符

android - 为什么我们不为 BOOT_COMPLETED 事件注册广播接收器

java - Android操作栏选项菜单项自定义可选背景

android - 如何自定义ActionBar背景图片?

android - PercentRelativeLayout 在 v26 中被弃用

java - 四元数对象旋转