Immediate Scrolling with RecyclerView & LinearLayoutManager

Nathan Sokalski 4,111 Reputation points
2022-12-18T22:15:58.98+00:00

I have a RecyclerView that uses a LayoutManager that inherits from LinearLayoutManager, in which I override the SmoothScrollToPosition method. Everything works perfect except for the time. I want the scroll to be immediate (0 seconds). I also inherit from LinearSmoothScroller & override CalculateDtToFit. I have found several methods when inheriting from LinearSmoothScroller, including CalculateSpeedPerPixel, CalculateTimeForDeceleration & CalculateTimeForScrolling, but none of them seem to do what I need. Is there any simple way to set the duration of the scrolling performed by SmoothScrollToPosition?

Developer technologies | .NET | Xamarin
0 comments No comments
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 50,126 Reputation points Microsoft External Staff
    2022-12-19T05:48:56.347+00:00

    Hello,

    On native Android, you could override those method you mentioned to change the speed of scrolling.

    However, there is no such an API to cancel the scrolling time to make scrolling be immediate (0 seconds).

    If you refer to the source code of the SmoothScrollToPosition method, the function called will eventually be called by the internal class of RecyclerView, ViewFlinger's postOnAnimation() method to play the scroll animation.

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.