Swiping Images in ViewFlipper or ViewPager
Asked Answered
I

1

14

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?

Idiolect answered 4/2, 2013 at 5:16 Comment(0)
T
25

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.

Tipper answered 4/2, 2013 at 5:29 Comment(4)
Thanks for an answer. Don't you think that ViewFlipper can use SwipeGesture to maintain the same set of operations as you just described. Don't you need to use Fragments for ViewPager?Idiolect
It may be possible, but it won't work "out of the box". However, that functionality is already built into ViewPager. And, as the name of the class implies, ViewPager pages views, not just fragments. Look here for example: #11640827Tipper
Thanks for the help here Oleg. Now trying to make a ViewPager to swipe through a set of images. Still have to look into how exactly ViewPager mechanism works. If you have a good link, please do share.Idiolect
Actually, I guess for images you may want to look into using the Gallery widget. Other than that, ViewPager is good for slightly more complicated views. See here for a few interesting topics.Tipper

© 2022 - 2024 — McMap. All rights reserved.