question

njsokalski avatar image
0 Votes"
njsokalski asked RobCaplan edited

Synchronizing Nested RecyclerView Scroll Positions

I have a RecyclerView whose Layout contains a RecyclerView. I want to synchronize the scroll positions of these nested RecyclerView(s). When synchronizing non-nested RecyclerViews, I created a RecyclerView.OnScrollListener & used the OnScrolled method, and then called the AddOnScrollListener method of the RecyclerView. However, because of the recycling feature of the RecyclerView, along with the fact that it has varying numbers of items, I am not sure how to do this for nested RecyclerView(s). What I basically need to do (or the best idea I could come up with) is set the scroll position for all the nested RecyclerView(s) from inside the OnScrolled method. However, because RecyclerView recycles the ViewHolder(s), this is not an option. Another option I thought of is to create an extra variable to hold the scroll position and then set it in OnBindViewHolder, but an extra variable seems inefficient. Any ideas?

dotnet-xamarin
· 7
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Synchronizing Nested RecyclerView Scroll Positions

Hi @njsokalski , I don't quite understand your means. What do you mean by words Synchronizing Nested RecyclerView Scroll Positions?
What features do you want to implement? Can you elaborate on that?

0 Votes 0 ·

I have a RecyclerView on my page. The ViewHolder/Layout used in the Adapter for that RecyclerView contains a RecyclerView. Therefore, I have a RecyclerView whose children are also RecyclerViews. When one of these child RecyclerViews is scrolled, I want the other RecyclerViews to scroll as well. Here is a screenshot:
88314-screenshot-1618500289.png
Each lightly colored column is a RecyclerView, which scrolls vertically. When one of these scrolls, I want the others to scroll as well. The black column on the left is a separate RecycerView, which I also want to synchronize with the nested RecyclerViews.

RecyclerView (Black)
RecyclerView
Nested RecyclerView
Nested RecyclerView
Nested RecyclerView
(More Nested RecyclerView(s))

I want the Black RecyclerView and all the Nested RecyclerView(s) to be synchronized.


0 Votes 0 ·

Sorry for replying so late due to our PT tool has not been updated in time.For this problem, it is generally not recommended to use another scroll control within a scroll control. This is most likely to cause problems with rolling collisions.

0 Votes 0 ·
Show more comments

0 Answers