首页 > 解决方案 > 带有nestedscrollview的嵌套RecyclerView不滚动

问题描述

我有一排在另一个recyclerview中有一个recyclerview,就像这张图片

在此处输入图像描述

我需要内部 recyclerview 才能滚动它,我已经尝试过了(这是在 ConstrainLayout 内)

<androidx.core.widget.NestedScrollView
    android:id="@+id/nested_scroll"
    android:layout_width="match_parent"
    android:layout_height="150dp"
    android:fillViewport="true"
    app:layout_constraintTop_toBottomOf="@+id/constraintLayout">

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

</androidx.core.widget.NestedScrollView>

rv_order_items.isNestedScrollingEnabled = true

但我无法在内部回收视图中滚动,有什么建议吗?

标签: androidkotlinandroid-recyclerviewnestedrecyclerview

解决方案


请在这篇文章中添加整个布局代码,以便我了解约束布局。


否则,如果您想全屏滚动,这是解决方案...
请设置android:layout_height="match_parent"NestedScrollView

<androidx.core.widget.NestedScrollView
android:id="@+id/nested_scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">

推荐阅读