简体   繁体   English

使用FragmentStatePagerAdapter的ViewPager滞后

[英]ViewPager Lag using FragmentStatePagerAdapter

I'm trying to build an application made of 10 Fragments using ViewPager along with FragmentStatePagerAdapter (and setOffScreenPageLimit(3) ). 我正在尝试使用ViewPager和FragmentStatePagerAdapter(以及setOffScreenPageLimit(3) )构建由10个片段组成的应用程序。 There are 5 Fragment which are going to perform realtime updates modifying TextViews, Graphs and ProgressBars (so they're always performing actions on the MainUi thread). 有5个片段将执行实时更新,以修改TextViews,Graphs和ProgressBars(因此它们始终在MainUi线程上执行操作)。 In this scenario, when I slide between Fragments the animation is very laggy (takes 1 to 2 seconds to change fragment when I see them for the first time, then it takes less but there are always lags). 在这种情况下,当我在“片段”之间滑动时,动画非常缓慢(第一次看到片段时需要1到2秒钟来更改片段,然后花费的时间更少,但总会有滞后)。

What I'm asking is: how can I improve the smoothness of transactions? 我要问的是:如何提高交易的顺畅度?

Should I change my way to implement fragments (using FragmentManager instead of ViewPager), slow down the animation or perform some sort of operations before the sliding? 我是否应该改变实现片段的方式(使用FragmentManager而不是ViewPager),放慢动画或在滑动之前执行某种操作?

I have not so much experience in Android so any help is appreciated. 我在Android方面没有太多经验,所以可以提供任何帮助。

最终,我找到了由setOffScreenPageLimit参数的增量组成的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM