现在的位置: 首页 > 综合 > 正文

ViewPager定时左右循环滚动

2018年02月24日 ⁄ 综合 ⁄ 共 1166字 ⁄ 字号 评论关闭

我在github 上面搜索到  InfiniteViewPager

github 上面的作者说对于 fragment
的size <4 的viewpager 支持不是很好 , 我自己down下来代码,就行了测试。 对于fragment的size >4 可以正常运行,但是对于size <4 的viewpager , 运行有bug。 
下面是作者的原话
:

I have experimented with
trying to block destroyItem() / calling instantiateItem() again if you are creating/destroying a page in the same round (between startUpdate() and finishUpdate()), but I didn't think it worked reliably enough and different implementations of destroyItem()/instantiateItem()
produced different results.


If you have a simple solution that works well with both FragmentPagerAdapter and FragmentStatePagerAdapter for low page counts, please let me know. For the time being, having less than four pages is unfortunately unsupported.


当你有三页,画面以外的页面被创建为您滚动是相同的一个被摧毁。这并不是一个问题,当你向前滚动,因为它将被摧毁,然后创建(依次)。当你向后滚动,它将被创建并摧毁了,净效应是一个空白页。

我已经尝试了试图阻止destroyItem()/调用instantiateItem()如果你创建/毁坏一个页面在同一轮之间(startUpdate()和finishUpdate()),但我不认为它足够可靠地工作,的不同实现destroyItem()/
instantiateItem()产生不同的结果。


如果你有一个简单的解决方案,顺利FragmentPagerAdapter和FragmentStatePagerAdapter低页面数量,请让我知道。目前,拥有不到四页是不幸的是不支持的。

这里我弄了半天没有弄出正确原因,我也是醉了!

项目里面吧 circleindicator 这个开源库添加进去了  ,运行效果如下:


项目代码下载地址 :    http://www.eoeandroid.com/thread-561505-1-1.html


如果有哪位大神解决了小于4页的问题(使用InfiniteViewPager2Activity作为主Activity),请告知下身为小白的我解决方法哈!

抱歉!评论已关闭.