image slider in recyclerview android

If you are looking for feature like Instagram where you can slide for multiple post in the list. Then this is right tutorial. They used image slider in recyclerview

If you want slider in single activty please read Adding slider image in android.

In this blog we will see how to add image slider in recyclerview android.

If you prefer to check code or need project download from github

image slider in recyclerview android

Project Structure

Project Structure


  1. Add Glide library for loading image(you can use Picasso as well)
  2. Add Internet permission in manifest.
  3. Design activity_main.xml
  4. Add single_recycler_item.xml
  5. Createlayout_slider.xml (new layout for viewpager)
  6. Create new Adapter for RecyclerView(
  7. Create new Adapter for viewpager( SliderPagerAdapter )
  8. Code in


Add glide library in your project buid.gradle

implementation ‘com.github.bumptech.glide:glide:4.11.0’


Add internet permission in AndroidManifest.xml


In activity_main.xml


In single_recycler_item.xml


In layout_slider.xml






Now In

That all, Save and run your project. You should able to see image slider in recyclerview.

Also read How to add navigation drawer androidx from here

Made with ❤

13 thoughts on “image slider in recyclerview android

  1. How do you add on click listener to the image?. I can only add to the dots and textview.

    1. Hey Pauril, If you need to add onclick listener, add it in SliderPagerAdapter not in ImageRecyclerAdapter since it is replaced with ViewPager…
      Here is the snippet in
      im_slider.setOnClickListener(new View.OnClickListener() {
      public void onClick(View v) {
      Toast.makeText(context, "image clicked", Toast.LENGTH_SHORT).show();

  2. Thanks sir. Can i pass the 4 urls to a full image viewer?

  3. On scroll listener too

    1. Hey Pula,I did’t get you.. Please elaborate your problem. Definitely I would love to help you
      Also make sure you are active in our youtube channel. we will be uploading android related video.

  4. Thank you sir. I wanted to only be loading 10 items in the recyclerview. Basically implement a pagination in the view. I am watching your videos thank you for the knowledge sharing

    1. Though I haven’t understand for which data you want to paginate here is how we can add paginate to your app with firebase. Click here

  5. […] Also read how to add simage slider in android. […]

  6. I want to paginate this recyclerview sir. I am fetching the images from MySQL with retrofit.
    See SO quiz

    1. Thank tenzin. That seem to be in kotlin. I a in java. My exact code is as above only that I am getting the data from a mysql server with retrofit

Leave a Comment

Your email address will not be published. Required fields are marked *