大家好,感谢您上次的帮助。也感谢你们在这方面给我的任何帮助!
所以我有amimationDrawable
一个硬币旋转。
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="true">
<item android:drawable="@drawable/coinflip1" android:duration="25" />
<item android:drawable="@drawable/coinflip2" android:duration="25" />
<item android:drawable="@drawable/coinflip3" android:duration="25" />
<item android:drawable="@drawable/coinflip4" android:duration="25" />
<item android:drawable="@drawable/coinflip5" android:duration="25" />
<item android:drawable="@drawable/coinflip6" android:duration="25" />
<item android:drawable="@drawable/coinflip7" android:duration="25" />
<item android:drawable="@drawable/coinflip8" android:duration="25" />
<item android:drawable="@drawable/coinflip9" android:duration="25" />
<item android:drawable="@drawable/coinflip10" android:duration="25" />
<item android:drawable="@drawable/coinflip11" android:duration="25" />
<item android:drawable="@drawable/coinflip12" android:duration="25" />
</animation-list>
这是我在点击按钮后旋转硬币的方法
public void spinCoin(){
final ImageView coinAmina = (ImageView) findViewById(R.id.imageView1);
coinAmina.setBackgroundResource(R.anim.coin_spin_heads);
coinAmina.post(new Runnable() {
@Override
public void run() {
frameAnimation = (AnimationDrawable) coinAmina.getBackground();
frameAnimation.start();
}
});
//end of coin spin
}
我AnimationDrawable frameAnimation;
之前也有onCreate
它运行良好,但我的问题是尝试运行它一段时间,例如 3 我试图循环coinSpin()
然后frameAnimation.stop
但没有好处
我也试过Thread.sleep(500)
了,setOneShot(false)
然后改成true
睡后
我想做的就是运行动画,无论我喜欢多少时间。另一个问题是当我有 2 个硬币可以旋转时,只有一个可以旋转,但这应该是另一个问题
我知道setOneshot(true)
运行它一次并false
一遍又一遍地运行它......但是我该如何阻止它
任何帮助将不胜感激