Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android : ViewFlipper Or ViewPager - Which is the better option?

I am getting stuck in one stage. I have a total of 20 to 25 images that should get animated like ViewPager does. Now on all the images I have onClick() events and I don't know if I should work with ViewPager or ViewFlipper. I can implement both things, no issues here.

What I Want : I just want a suggestion that according to my problem which will be the best option, ViewFlipper or ViewPager?

What I Have Searched : I have gone through different links on StackOverflow, namely How to improve the performance of ViewFlipper/ViewAnimator and ViewFlipper vs Fragments, but I could not find the thing I want.

I have worked with ViewPager somewhat, but at that time there were just 3 or 4 Fragments I had to manage. If I were to use it to solve this problem I have to manage 25 Fragments this time. So I am wondering if there is a better solution available.

I have also done a little R & D on ViewFliper and know that it has only one Activity I have to manage but it does not have the animation accuracy that ViewPager has.

Please suggest me whether I should go for ViewPager or ViewFlipper?

Thanks in Advance.

like image 352
Bhavesh Patadiya Avatar asked Oct 23 '12 13:10

Bhavesh Patadiya


People also ask

What is ViewPager used for?

Layout manager that allows the user to flip left and right through pages of data. You supply an implementation of a PagerAdapter to generate the pages that the view shows. ViewPager is most often used in conjunction with android.

What is ViewFlipper in android?

android.widget.ViewFlipper. Simple ViewAnimator that will animate between two or more views that have been added to it. Only one child is shown at a time. If requested, can automatically flip between each child at a regular interval.


1 Answers

intro: On first thought I would recommend Gallery widget instead of ViewFlipper but it is depreciated (0.o) since JellyBean (API 16), probably because of bad recycling of nonvisible elements implementation.

answer: What u really should use now is ViewPager or HorizontalScrollView. In your case (despite not too much given details) I think is better ViewPager because according to documentation:

.. HorizontalScrollView is a FrameLayout, meaning you should place one child in it, containing the entire contents to scroll ..

On the other side for ViewPager you should implement PagerAdapter to generate pages which will be shown in this view.

My final answer is A, ViewPager ;)

Hope u will find this helpful ;) Cheers

like image 127
Ewoks Avatar answered Oct 14 '22 18:10

Ewoks