【发布时间】:2011-05-10 23:27:08
【问题描述】:
我试图让我的动画只运行 6 次,我设置了 oneshot="true" 并尝试循环播放动画但它不起作用,动画仍然只运行一次。
非常感谢任何帮助。
这是代码
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="true">
<item android:drawable="@drawable/image" android:duration="100" />
<item android:drawable="@drawable/image1" android:duration="100" />
<item android:drawable="@drawable/image2" android:duration="100" />
<item android:drawable="@drawable/image3" android:duration="100" />
<item android:drawable="@drawable/image4" android:duration="100" />
</animation-list>
.
for (int i = 0; i < 5; i++){
img.setBackgroundResource(R.anim.anime);
AnimationDrawable frameAnimation = (AnimationDrawable)img.getBackground();
frameAnimation.setCallback(img);
frameAnimation.setVisible(true, true);
frameAnimation.start();
}
【问题讨论】:
-
您需要等待每次运行完成才能开始下一次运行。
-
@Amanni:你必须将 oneshot 设置为 false 而不是 true。并尝试使用 android:repeatCount 属性