目前,我正在编写一个应用程序,它使用动画列表显示一组正在着色的按钮的框架。它看起来像
<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毫秒左右)。如果有可能的话,加速动画的最佳方法是什么?
谢谢!
你必须使用喜欢
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>