question

njsokalski avatar image
0 Votes"
njsokalski asked RobCaplan edited

OnScrollListener When Scrolling 0

I have several RecyclerView(s) which I need to keep synchronized. This is very easy when the user is manually scrolling, but when I need to scroll programmatically using SmoothScrollToPosition and an OnScrollListener it does not always seem to work. Sometimes the OnScrolled event of the OnScrollListener is not triggered for all the RecyclerView(s) or the dy parameter of OnScrolled recieves a value of 0. to which I have attached it (using AddOnScrollListener). I have created/overridden the following classes/methods:

SmoothScrollToPosition from LinearLayoutManager
CalculateDtToFit from LinearSmoothScroller
OnScrolled from OnScrollListener

I'm not sure how to make sure the OnScrollListener(s) are always triggered so that I can keep all the RecyclerView(s) in sync. How can I do this?

dotnet-xamarin
· 1
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.

the dy parameter of OnScrolled recieves a value of 0

Hi, njsokalski. The dy is the amount of vertical scroll. If the value is 0, that means there is no scrolling. In this case, the onScrolled callback will only be called if visible item range changes after a layout calculation. Check the doc.

0 Votes 0 ·

0 Answers