Android Viewpager 动画断断续续

发布于 2024-12-28 06:51:56 字数 495 浏览 7 评论 0原文

我在 ViewPager 中添加了大约 4 个(列表)视图,它充当 TabHost 的控制器。与此处找到的示例类似的内容:

http://developer.android.com/resources/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentTabsPager.html

当我滑动手指转到下一个时看来,不是很顺利。我使用 setDrawingCacheEnabled(true); 来改进动画。不过,看起来还是很不稳定。 任何人都可以提供任何指导来获得流畅的动画吗?

I have around 4 (list)views added to my ViewPager which acts as a controller to a TabHost. Something similar to example found here :

http://developer.android.com/resources/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentTabsPager.html

When I fling my finger to go to next view, its not very smooth. I have used the setDrawingCacheEnabled(true); to improve on the animation. Still, it seems choppy.
Can anyone provide any guidelines to have smooth animations ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蓝颜夕 2025-01-04 06:51:56

这里只是一个大胆的猜测,但是填充 ListViews 是否可能需要太多时间,从而导致动画断断续续,因为 ViewPager 必须等待下一个 View 被实例化?我也遇到过类似的问题,我发现原因是在 ListAdapter 的 getView() 中调用 SQLite 函数,导致延迟。

Just a wild guess here, but is it possible that populating the ListViews takes too much time, thus causing the choppy animations as the ViewPager has to wait for the next View to be instantiated? I've had a similar problem, the cause of which I found out to be SQLite functions being called in a ListAdapter's getView(), causing the delay.

蛮可爱 2025-01-04 06:51:56

尝试在扩展 pagerAdapter 示例的 Adapter 处设置布局参数

TextView txt = new TextView(context);
txt.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

try set the layout parameters at Adapter which extends the pagerAdapter example

TextView txt = new TextView(context);
txt.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文