gpt4 book ai didi

java - 如何加快 Android Studio 中的动画列表速度?

转载 作者:太空宇宙 更新时间:2023-11-04 10:39:44 24 4
gpt4 key购买 nike

目前,我正在编写一个应用程序,它使用动画列表来显示一组用于着色按钮的框架。它看起来像

<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="true">
<item android:drawable="@drawable/mathematics_0" android:duration="1" />
<item android:drawable="@drawable/mathematics_1" android:duration="1" />
<item android:drawable="@drawable/mathematics_28" android:duration="1" />
</animation-list>

我将动画中的各个项目的持续时间设置为 1,但它似乎对速度没有任何大的影响。如果我理解动画持续时间文档,它应该以毫秒为单位,这意味着我的 29 项动画列表应该花费 29 毫秒。然而,它似乎花费了比 29 毫秒长得多的时间(大约 500 毫秒左右)。如果可能的话,进一步加快动画速度的最佳方法是什么?

谢谢!

最佳答案

你必须使用like

ImageView img = (ImageView)findViewById(R.id.ivAnimImage);
AnimationDrawable frameAnimation = (AnimationDrawable)img.getDrawable();
frameAnimation.setCallback(img);
frameAnimation.setVisible(true, true);
frameAnimation.start();

在动画文件中

<animation-list   android:id="@+id/my_animation" android:oneshot="false" 
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/frame1" android:duration="15" />
<item android:drawable="@drawable/frame2" android:duration="15" />

</animation-list>

关于java - 如何加快 Android Studio 中的动画列表速度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49123357/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com