Image Slider With Slideshow Using Viewpager Android Studio Example

Hello, dear developers. In image slider with slideshow using Viewpager android studio example, you will learn how to create image slider in the Android app.

You can also call it as a slideshow.

We will use Viewpager to develop this tutorial programmatically.

First, check the output and then we will go on to develop image slider with slideshow using a Viewpager android studio.

How to get maximum benefit from image slider with slideshow using Viewpager android studio Tutorial

Download Source Code

Try Our App

Download DemoNuts app to learn anytime, anywhere: Click to get Demonuts App

Or search “demonuts” in play store from android mobile device.

Creating Image Slider With Slideshow Using Viewpager Android Example

If you are using adblocker, then you will not be able to show our site smoothly. For example, you find step 6 after step 1 or similar to this. So please disable adblocker to fully utilize all resources of DemoNuts

Step 1: Create a new project in Android Studio.

Step 2: Updating build.gradle(Module:app) file

Add following code into dependencies{} 

Step 3: Adding Images into Drawable directory

Download and add following images into drawable directories.


After adding images, a directory will look like below image.

image slider slideshow viewpager android

drawable directory

Step 4: Creating class

Create a new class and name it as and add below code

Step 5: Creating Layout resource for single slide

Create one layout resource file under layout directory and name it as slidingimages_layout.xml

add following code:

Step 6: Preparing Adapter class for Viewpager

Open a new Java class and name it as

Copy and paste below

Step 7: Updating activity_main.xml file

Copy and paste following

Step 8: Updating file

Update MainActivity with below source code

Step 9: Stopping Auto Slider

See following code which is responsible for auto sliding of image

If you want to stop automatic sliding of an image, comment out above code.

Here images will be slide every 3 seconds. You can change it by updating

3000,3000); values in above source code.

How to get exact Android example while searching in Google

Click to get Important Google searching tips

So it was all about image slider with slideshow using Viewpager android example. Thank you ?

Hardik Parsania

I am mobile app developer. I am always passionate about solving complex and real world problems.I have developed many apps with great interest and superior logical skills.

You may also like...

15 Responses

  1. Kyle marsh says:

    Very informative and useful. Thanks!

  2. خانه اندروید says:

    hi admin very good post

  3. Wallison Gomes says:

    Hello, Hardik Parsania.
    Execelente project, I really liked it !!!
    How could it be possible to make the images pass randomly rather than in sequence?

    Well I will use around 100 photos, but I did not want them to remain in the same position, I would like them to be random.

    How can I implement this solution?

    Thank you very much for sharing your knowledge !!!

  4. Hardik Parsania says:

    Hello, Thank you for your review.
    You can shuffle arraylist which is passed into the adapter.

  5. vishal kumar jaiswal says:

    Thanks for this tutorial

  6. Danu Prakoso says:

    is it automatic?

  7. jitendra says:

    nice tutorial

  8. Amol says:

    I want to add Star Rating in image and image and description should come from database,how will i do it please tell me

  9. Rashi says:

    Hello, Hardik Parsania.
    How to fetch the image from server using URL.

Leave a Reply

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