Open In App

How to Add Fast Scroller in RecyclerView using Recycle-Fast-Scroll?

Last Updated : 03 Apr, 2023
Like Article

In this article, we are going to implement fast-scroll using the recycle-fast-scroll library. For the item, in the RecyclerView we are just implementing a button and the total number of buttons will be set by us in the MainActivity. The name of the button will be the position of the button. A sample GIF is given below to get an idea about what we are going to do in this article. Note that we are going to implement this project using the Java language. 

Step by Step Implementation

Step 1: Create a new Project

To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. Note that select Java as the programming language.  

Step 2: Add this into build.gradle:(app) file

implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.github.plusCubed:recycler-fast-scroll:0.3.2'
implementation ''

Add this into build.gradle:(project) file

allprojects {
    repositories {
        maven { url '' }

Step 3: Working with the items.xml file

Go to the app > res > layout > New > Layout Resource File and name the file as item. Go to the item.xml file and refer to the following code. Below is the code for the item.xml file.


<?xml version="1.0" encoding="utf-8"?>
        android:text="Click Here" />

Step 4: Working with the file

Create a new java class in android studio and name the class as RecyclerViewAdapter. Go to the file and refer to the following code. Below is the code for the file. 


import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.ViewHolder> {
    private int mcount;
    public RecyclerViewAdapter(int mcount) {
        this.mcount = mcount;
    public RecyclerViewAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.items, parent, false);
        return new ViewHolder(view);
    public void onBindViewHolder(@NonNull RecyclerViewAdapter.ViewHolder holder, int position) {
        // Adding the items in recycler view with name "Button" + position
        holder.itemclick.setText("Button" + position);
    public int getItemCount() {
        return mcount;
    public class ViewHolder extends RecyclerView.ViewHolder {
        Button itemclick;
        public ViewHolder(@NonNull View itemView) {
            itemclick = itemView.findViewById(;

Step 5: Working with the activity_main.xml file

Navigate to the app > res > layout > activity_main.xml and add the below code to that file. Below is the code for the activity_main.xml file. 


<?xml version="1.0" encoding="utf-8"?>
        android:layout_height="match_parent" />
        app:rfs_handlePressedColor="#df56C6" />

Step 6: Working with the file

Go to the file and refer to the following code. Below is the code for the file. Comments are added inside the code to understand the code in more detail.


import android.os.Bundle;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.pluscubed.recyclerfastscroll.RecyclerFastScroller;
public class MainActivity extends AppCompatActivity {
    RecyclerView recyclerView;
    RecyclerFastScroller fastScroller;
    protected void onCreate(Bundle savedInstanceState) {
        // initialising the recycler view
        recyclerView = findViewById(;
        recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
        // Initialising the size of recycler as 50
        recyclerView.setAdapter(new RecyclerViewAdapter(50));
        fastScroller = findViewById(;


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads