无法隐藏工具栏 + 回收站视图

Unable to hide the Toolbar + Recycler View

i 在不使用折叠工具栏的情况下创建了一个工具栏。我需要隐藏工具栏向上滚动 Recycler view.i followed link for scrolling/hiding toolbar

http://android-developers.blogspot.com/2015/05/android-design-support-library.html

这是我的 xml

<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.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_scrollFlags="scroll|exitUntilCollapsed" />
</android.support.design.widget.AppBarLayout>

<android.support.v7.widget.RecyclerView
    android:id="@+id/recycler_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="vertical"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" /></android.support.design.widget.CoordinatorLayout>

这是我的输出 我不确定哪里出了问题。我做对了每一件事。但是在滚动回收器视图时,工具栏保持在同一位置。它没有隐藏。

非常感谢您的帮助。

wrap_content 用于 Toolbar 存在已知问题。相反,使用固定高度:

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    app:layout_scrollFlags="scroll|enterAlways" />

您会注意到我使用 scroll|enterAlways - exitUntilCollapsed 仅在您使用 CollapsingToolbarLayout(或任何具有不同 layout_heightminHeight).

还要确保 build.gradle 至少 buildToolsVersion "22.0.1"

compile 'com.android.support:design:22.2.0'
compile 'com.android.support:recyclerview-v7:22.2.0'