AUTO IMAGE SLIDER

Vijay Gupta
imageslider in android studio
3 min readJul 28, 2018

--

Android Development become very common nowadays and everybody is trying to develop some outstanding applications. In this competitive world , it is very tough to stand out of the queue while on the other hand there are plenty of resources that are helpful in many ways.

ADDING AN IMAGE SLIDER IN ANDROID STUDIO PROJECT USING VIEW FLIPPER.

While i was about to add Image slider in my android studio project i was also seeking for any help on internet.But i can’t find any thing much helpful. It took a lot of time to finally implement image slider in my android studio project. So finally i have a found a solution, i would like to share it.

  • What is Image slider and how it is helpful?

Image slider is a Pre-defined layout in which you can add multiple images and you can see those images with sliding feature (either manually or automatically). We can implement Image slider using VIEW FLIPPER . It become very simple to implement image slider using view flipper. You just need to add images in the View Flipper (that you can define in XML file of your project).

You have seen on some websites or applications that images are continously changing without any action performed on them. That is nothing but just a VIEW FLIPPER and we can also add them in our android application.

STEP -1

Open your activity.xml file of the activity in which you want to add IMAGE SLIDER in android studio project.

STEP -2

Add view flipper inside the .xml file and add images inside the view flipper (on which you want to perform sliding action ). You can implement image slider in two ways.

  1. Auto image slider. In this you don’t need to perform any action. You just need to define the time interval between two images in xml file.

In this way you can add auto image slider in your android studio project.

Just make sure you add the two lines in which comments are added to start an auto image slider. Flip interval in the above image is 3 seconds.

Above image is the .xml file of my project. and below are some images from my android application’s auto image slider.

1-)

2-)

3-)

2) Image slider using buttons and view flipper.

In this type image flipping is done by using buttons. Everything is same as per the above approach. In this you just need to add two buttons and call the functions

Example-

These two buttons are defined for the next and previous slide.

Mainactivity.java code -

For the complete code-

.XML file- https://github.com/guptavijay/indian_air_force/blob/master/app/src/main/res/layout/activity_honours.xml

Mainactivity-https://github.com/guptavijay/indian_air_force/blob/master/app/src/main/java/com/example/hp/indian_air_force/Honours.java

Hope this is helpful.

--

--