我想制作一个动画,但能够按照我想要的次数播放它.现在它只是第一次播放.
.XML:
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/p1_ch1" android:oneshot="true">
<item
android:drawable="@drawable/p1_ch1_5"
android:duration="500"/>
<item
android:drawable="@drawable/p1_ch1_4"
android:duration="1000"/>
<item
android:drawable="@drawable/p1_ch1_5"
android:duration="500"/>
</animation-list>
的.java:
public void handler_p1_ch1_5 (View target){
ImageView iv = (ImageView)findViewById(R.id.p1_ch1_5);
AnimationDrawable aw = (AnimationDrawable)iv.getBackground();
aw.start();
}
解决方法
只需在aw.start()之前调用aw.stop()