InListView, you could have a fast scroller which allowed you to drag a scrollbar to easily scroll to wherever you wished using fastScrollEnabled attribute.With Support Library 26, you can also easily enable fast scrolling for RecyclerView.

Fast Scrolling RecyclerView

Add Dependency


Support Library 26 has now been moved to Google’s maven repository, first include that in your project level build.gradle.

Add Support Library 26 in your app level build.gradle.

Enable Fast Scrolling


If fastScrollEnabled boolean flag for RecyclerView is enabled then,fastScrollHorizontalThumbDrawable,fastScrollHorizontalTrackDrawable, fastScrollVerticalThumbDrawable, and fastScrollVerticalTrackDrawable must be set.

  • fastScrollEnabled : Setting this as true will require that must provide the following four properties.
  • fastScrollHorizontalThumbDrawable :  StateListDrawable used for drawing the thumb which will be draggable across the horizontal axis.
  • fastScrollHorizontalTrackDrawable : StateListDrawable used for drawing the line that will represent the scrollbar on the horizontal axis.
  • fastScrollVerticalThumbDrawable : StateListDrawable used for drawing the thumb which will be draggable on the vertical axis.
  • fastScrollVerticalTrackDrawable : StateListDrawable used for draw the line that will represent the scrollbar on the vertical axis.

 

Now, Create native shapes StateListDrawables.

line.xml

line_drawable.xml

thumb.xml

thumb_drawable.xml

 

Now Create RecyclerView and enable fastScrollEnabled.

 

Download this project from GitHub