Loading...

Android Image Slider Tutorial

Many android applications display images with sliding effect and with page indicator. In this android tutorial, you will learn to create an image slider in your own application. Creating (making) an image slider in android app is very simple; you just need to write some lines of code. Image slider is the transition between one entire screen to another and it is also known as slideshows. We will use ViewPager to develop image slider android app.

ViewPager allows us to swipe a screen left and right and here we will pass images to ViewPager to display new image when screen is swipe.

Related:
Adding Ripple Effect/Animation on Android Image View
Implement Zoom Effect in Android ImageView Images
Android ImageSwitcher Example

Android Example: How to Make Image Slider (Slideshow) Application


Create a new android application File >> New Android Project and fill up required information with java activity file name AndroidImageSlider and XML layout file name android_image_slider_activity.

Image Slider Tutorial Demo Video:




XML Layout File

Open your app XML layout file and add a ViewPager inside RelativeLayout or LinearLayout with id name viewPageAndroid, layout_width=match_parent and layout_height=match_parent. Following is the complete content of XML layout file.

res/layout/android_image_slider_activity.xml

Java Activity File

Create a new java activity file for PageAdapter with file name AndroidImageAdapter and extend it to PagerAdapter. Here you need to add images to display in slideshow and much other java code. Following is the complete java code of AndroidImageAdapter.java file.

src/AndroidImageAdapter.java

Now open your main java activity file and declare the ViewPager and set the adapter view. Following is the complete java code of main java activity file.

src/AndroidImageSlider.java

 Android Example: How to Make Image Slider (Slideshow) Application

That’s all. Now run your Android Image Slider Example application and swipe the screen right and left, different images will appear there. This application will look like above screenshot and demo video.
UI 4468847488578637210
Home item