首页 > 解决方案 > 与 CollapsingToolbarLayout 一起使用时,Recycler View 不会过度滚动

问题描述

我有以下带有可折叠工具栏布局和回收站视图的布局。不知何故,它不允许 recyclerview 过度滚动。我怎样才能做到这一点?谢谢!

<com.google.android.material.appbar.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar_layout"
        android:layout_width="match_parent"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">


        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            style="@style/ToolbarStyle"
            android:layout_width="match_parent"
            android:layout_height="?android:attr/actionBarSize">
    </com.google.android.material.appbar.CollapsingToolbarLayout>

</com.google.android.material.appbar.AppBarLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

    <View
        android:id="@+id/view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/recycler_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clipToPadding="false"/>

</LinearLayout>

标签: androidandroid-recyclerviewandroid-collapsingtoolbarlayoutoverscroll

解决方案


CoordinatorLayout 1.1.0(Material 1.1.0 的基础)和RecyclerView 1.1.0的很大一部分正在迁移到新的嵌套滚动 API,这些 API 专门用于解决过度滚动无法在视图之间正确传输的情况.

您应该升级到 Material 1.1.0 和 RecyclerView 1.1.0。


推荐阅读