Home > Back-end >  Nested Recycler Views, Vertically Scrolled ( Parent using Pagination )
Nested Recycler Views, Vertically Scrolled ( Parent using Pagination )

Time:06-25

<androidx.recyclerview.widget.RecyclerView
                android:id="@ id/rv_sales_report"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_marginTop="20dp"
                android:clipToPadding="false"
                android:paddingHorizontal="10dp"
                android:paddingBottom="120dp"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/mtv_sales_report_date"
                tools:listitem="@layout/item_reportings_new" />
  <androidx.recyclerview.widget.RecyclerView
                android:id="@ id/rv_dynamic_inner_reporting"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:orientation="vertical"
                android:paddingBottom="10dp"
                app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
                app:layout_constraintTop_toBottomOf="@id/mtv_date_dynamic"
                tools:listitem="@layout/item_inner_reporting" />

The inner recycler view is not scrolling I have tried many solutions, non helped me, how can I make the inner recycler view scroll vertically, they both scroll vertically.

CodePudding user response:

android:layout_height="0dp" You shouldn't use this without setting either the layout weight or without constraining both the top and bottom of the view because without constraints, it might just act as wrap_content basically extending beyond the screen.


Also, for the inner view, if the orientation is vertical, then height shouldn't be wrap_content maybe changing that would help.


Also, just a tip, having both recycler be vertical is a bad idea because how would android (or the user) know which view you are scrolling on if they are together.

CodePudding user response:

Issue is solved by showing only four items in the inner Recycler View, and enabling nestedScrollView = true, also handling OnTouch Events for the parent Recycler View.

  • Related