【问题标题】:Overscroll effect is not displayed correctly in NestedScrollView with RecyclerView inside在带有 RecyclerView 的 NestedScrollView 中无法正确显示过度滚动效果
【发布时间】:2020-12-05 02:05:02
【问题描述】:

我有包含一些视图和 RecyclerView 的 NestedScrollView。但是当我滚动 RecyclerView 时,过度滚动的效果只显示在里面。如何在 NestedScrollView 中显示?

我可以使用android:overScrollMode="never" 在 RecyclerView 中禁用过度滚动效果,但我不知道如何在滚动 RecyclerView 时在 NestedScrollView 中启用过度滚动效果。我已经尝试了所有明显的解决方案。

<androidx.core.widget.NestedScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <!-- My views here -->

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

    </LinearLayout>

</androidx.core.widget.NestedScrollView>

PS:我需要将我的一些视图放在 RecyclerView 之外,否则 RecyclerView 适配器会变得不必要地复杂(有必要描述所有类型的元素)。请不要说这对性能不利。就我而言,这无关紧要。

【问题讨论】:

    标签: android android-recyclerview android-nestedscrollview android-scroll android-overscoll


    【解决方案1】:

    请通过NestedScrollView reference document了解更多信息。

    并将recyclerView.setNestedScrollingEnabled(false); 添加到您的RecyclerView

    【讨论】:

      猜你喜欢
      • 2016-10-20
      • 1970-01-01
      • 2016-04-24
      • 2021-01-21
      • 1970-01-01
      • 2022-09-23
      • 1970-01-01
      • 2017-01-16
      • 2017-05-13
      相关资源
      最近更新 更多