Control Smooth Scroll over Recycler View

In this post I will show you how can you achieve smooth scroll over RecyclerView

The key to a smoothly scrolling RecyclerView is to keep the application’s main thread (the UI thread) free from heavy processing. Recycler view is a flexible view for providing a limited window into a large data set.

Making Listview smooth there are many examples but none for the RecyclerView. Sometime its happen that user fling the screen so fast that RecyclerView looks shaky. It leave bad impression on the user.

For smooth scroll we need to control fling of the user. I have made custom class that extends RecyclerView. This can be achieve in just 3 steps.

Step 1 :

Create CustomRecyclerView Class. Below class is particular for Vertical RecyclerView.

For Horizontal RecyclerView just change fling method.

Step 2:

Because of we are using custom class for the RecyclerView we need to use class name with package name in the XML layout as well.

 

For example your create CustomRecyclerView under com.sid.views then in XML it will be com.sid.views.CustomRecyclerView

Step 3:

And the last step for reading custom class in the java. We need to use like that. This is TypeCasting to our Custom class.

 

You can get complete class from GitHub. For more information regarding smooth scroll go to this Question.

Thank you for Reading