Android : ViewFlipper 或 ViewPager - 哪个是更好的选择?

Android : ViewFlipper Or ViewPager - Which is the better option?(Android : ViewFlipper 或 ViewPager - 哪个是更好的选择?)

本文介绍了Android : ViewFlipper 或 ViewPager - 哪个是更好的选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我陷入了一个阶段.我总共有 20 到 25 张图像应该像 ViewPager 那样进行动画处理.现在在所有图像上我都有 onClick() 事件,我不知道我是否应该使用 ViewPagerViewFlipper.我可以实现这两件事,这里没有问题.

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.

我想要什么:我只是想要一个建议,根据我的问题,哪个是最佳选择,ViewFlipper 还是 ViewPager?

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

我搜索过的内容: 我浏览过 StackOverflow 上的不同链接,即 如何提高 ViewFlipper/ViewAnimator 的性能 和 ViewFlipper vs Fragments,但我找不到我想要的东西.

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.

我曾在一定程度上使用过 ViewPager,但当时我只需要管理 3 或 4 个 Fragments.如果我要用它来解决这个问题,这次我必须管理 25 个 Fragments.所以我想知道是否有更好的解决方案.

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.

我也做了一点R&D on ViewFliper 并且知道它只有一个 Activity 我必须管理,但它没有 ViewPager 具有的动画准确性.

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.

请建议我应该选择 ViewPager 还是 ViewFlipper?

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

提前致谢.

推荐答案

intro: 一开始我想我会推荐 Gallery 小部件而不是 ViewFlipper 但它自 JellyBean (API 16) 以来已贬值 (0.o),可能是因为不可见元素实现的回收不良.

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.

回答:你现在真正应该使用的是 ViewPager 或 Horizo​​ntalScrollView.在你的情况下(尽管没有太多的细节)我认为更好 ViewPager 因为根据文档:

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:

.. Horizo​​ntalScrollView 是一个 FrameLayout,意味着你应该放置一个子在其中,包含要滚动的全部内容..

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

在 ViewPager 的另一边,你应该实现 PagerAdapter 以生成将在此显示的页面查看.

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

我的最终答案是A,ViewPager ;)

My final answer is A, ViewPager ;)

希望你会觉得这很有帮助;)干杯

Hope u will find this helpful ;) Cheers

这篇关于Android : ViewFlipper 或 ViewPager - 哪个是更好的选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:Android : ViewFlipper 或 ViewPager - 哪个是更好的选择?