android - 嵌套的 RecyclerView 不滚动

标签 android kotlin android-recyclerview

我在另一个回收站 View 中添加回收站 View 时遇到问题。子回收器位于 CardView 内,而 CardView 位于父回收器 View 内。我尝试了互联网上的所有解决方案,但没有用。我希望子回收器 View 垂直滚动,而父回收器 View 也垂直滚动。

父回收者 View :

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/backgroundPrimary"
    tools:context=".BidsCenter">

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/bidCenter"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="5dp"
        />
</FrameLayout>

child 回收站 View :

<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="5dp"
    android:animateLayoutChanges="true"
    android:clickable="true"
    android:elevation="3dp"
    android:focusable="true"
    android:orientation="vertical"
    app:cardCornerRadius="10dp">
    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="5dp">

        <RelativeLayout
            android:id="@+id/r0"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <ImageView
                android:id="@+id/itemPreviewInCenter"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_alignParentEnd="true"
                android:layout_centerVertical="true"
                android:layout_margin="3dp"
                android:scaleType="fitCenter"
                android:src="@android:drawable/ic_menu_report_image" />

            <TextView
                android:id="@+id/itemTitleInCenter"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_margin="3dp"
                android:layout_toStartOf="@+id/itemPreviewInCenter" />

            <TextView
                android:id="@+id/totalBidPrice"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_centerVertical="true"
                android:layout_toEndOf="@+id/numberOfBids"
                android:background="@drawable/bid_total"
                android:clickable="false" />

            <TextView
                android:id="@+id/latestBidDate"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_margin="3dp"
                android:layout_toEndOf="@id/bidMenu" />

            <TextView
                android:id="@+id/numberOfBids"
                android:layout_width="25dp"
                android:layout_height="25dp"
                android:layout_centerVertical="true"
                android:layout_margin="3dp"
                android:layout_toEndOf="@+id/latestBidDate"
                android:background="@drawable/new_message_count"
                android:gravity="center"
                android:textColor="@color/text"
                android:visibility="gone" />

            <ImageButton
                android:id="@+id/bidMenu"
                style="?android:attr/actionOverflowButtonStyle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentStart="true"
                android:layout_centerVertical="true" />
        </RelativeLayout>

        <LinearLayout
            android:id="@+id/showBidders"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/r0"
            android:orientation="vertical"
            android:visibility="gone">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="end"
                android:layout_margin="3dp" />

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/latestBidsInCenter"
                android:layout_width="match_parent"
                android:layout_height="120dp" />
        </LinearLayout>
    </RelativeLayout>
</androidx.cardview.widget.CardView>

这里有一些截图

parent : enter image description here

child : enter image description here

最佳答案

android:nestedScrollingEnabled="false" 添加到您的子 RecyclerView ,它应该可以工作。

关于android - 嵌套的 RecyclerView 不滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59973757/

相关文章:

android - 通过代码将图层列表设置为 View 的背景

android - 我怎样才能保持每 5 秒请求一次页面而不耗尽电池电量?

kotlin - Kotlin 中是否有一个可实例化的 MutableList,避免使用 java api?

java - 使用圆角背景在滑动时删除项目

android - RecyclerView 删除项目不调用 OnScrollListener

android - 如果在 nestedScrollView 内,RecyclerView 不回收

android - 背景时如何使 Activity 模糊?

android - 如何在移动应用程序的 sails.js 中从以前的设备注销用户?

kotlin - 为什么 Kotlin 隐式调用属性的 getter 和 setter?

java - 使用 Axon 跨不同 JVM 的多个传奇(相同类型)