androidandroid-recyclerviewandroid-handlerandroid-scroll

Auto smooth scrolling in Recycler view


I use smooth recyclerView.smoothScrollBy(int dx , int dy) for scrolling. Put this method in handler and call the handler every 50 miliseconds. my speed range is 0 - 10. Runnable of handle scrolling is

   private Runnable runnableMove = new Runnable() {
    @Override
    public void run() {
        recyclerView.smoothScrollBy(0,speed * 4);
        handler.postDelayed(this,50);   
   };

Suddenly scrolling starts to lagging. And i must stop scrolling and start it again.

This is important and I sync 2 device and more (maybe 4 , 5) with the same item in recycler view and I need the scroll position of any of them to sync them together.

Most of the time one or two of the devices is slower or faster in scrolling. I need all device scroll with the same speed. How can I solve this problem in android.


Solution

  • I found this method and it works for me:

    recyclerView.smoothScrollBy(dx, dy, new LinearInterpolator(), time);