Swiping Images in ViewFlipper or ViewPager

Ahmed picture Ahmed · Feb 4, 2013 · Viewed 9.4k times · Source

I want to show an image at a time. On a swipe I want to change my image with sliding effect. I read about ViewPager and ViewFlipper. I even have an example of doing such with ViewFlipper. Just need a proper explanation on where to use ViewFlipper and where to use ViewPager. It seems to me as if ViewPager is more likely to be used when you want to swipe bunch of fragments which holds some functionality as well rather than just having some images to swipe.

However if some one thinks that ViewPager should be used instead of ViewFlipper just to swipe bunch of images, please briefly explain why? Why should a person use ViewPager instead of ViewFlipper. Which one should be more memory efficient? And whats the purpose of these two? Could you please illustrate an example (code) swiping imageViews?

Answer

Oleg Vaskevich picture Oleg Vaskevich · Feb 4, 2013

ViewPager and ViewFlipper actually work a bit differently. ViewFlipper doesn't let you swipe and drag the images - you basically flick your finger and then the currently shown image flips right at a constant speed.

ViewPager, on the other hand, lets the user press and hold the view and slide it left/right. It is probably more user friendly as it has more feedback (i.e. the user can decide not to flip an image even when he/she already started flicking the image in one direction). So I would use ViewPager. Regardless, both have ways of being optimized for memory, depending on the adapter that you use.