同步滚动垂直一个视图中的多个水平回收器视图

我有一个垂直的RecyclerView,其中每一行都是一个水平的RecyclerView。 我想做的是,无论您滚动哪个水平的RecyclerViews,其他所有视图都会一起滚动。

这是我的代码:

垂直Recyclerview:

 <androidx.recyclerview.widget.RecyclerView
                    android:id="@+id/purchase_ticket_seats_view"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    tools:listitem="@layout/view_seats_horizontal"
                    android:nestedScrollingEnabled="false"/>

在Vertical Recyclerview内部查看:

    <?xml version="1.0" encoding="utf-8"?>
   <androidx.constraintlayout.widget.ConstraintLayout 
    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:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    >


    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/seats_horizontal_view"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:nestedScrollingEnabled="false"
        android:orientation="horizontal"
        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
        tools:listitem="@layout/view_seat"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@+id/seat_row_name" />


    <TextView
        android:id="@+id/seat_row_name"
        android:layout_width="30dp"
        android:layout_height="match_parent"
        android:text="A"
        android:textSize="18sp"
        android:paddingStart="5dp"
        android:paddingEnd="3dp"
        android:paddingTop="7dp"
        android:textColor="#fff"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>

我尝试过将垂直recyclerview放在水平滚动视图中,并禁用水平recyclerview的水平滚动。但是没有运气。我还尝试为水平recyclerview提供相同的滚动侦听器。

这是我想要获得的图像。用户可以垂直滚动,如果用户滚动一个水平行,其他用户可以一起滚动:

同步滚动垂直一个视图中的多个水平回收器视图

fangshijie66 回答:同步滚动垂直一个视图中的多个水平回收器视图

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2569161.html

大家都在问