をクリックすると、AnimationDrawable を使用してフレーム間アニメーションを表示しようとしていますImageView
。しかし、私のアニメーションは、 をクリックしたときに一度だけ発生しますImageView
。アニメーションにはxmlを使用しています。
アニメーション XML:
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="true">
<item android:drawable="@drawable/scorepopup1" android:duration="100" />
<item android:drawable="@drawable/scorepopup2" android:duration="100" />
<item android:drawable="@drawable/scorepopup3" android:duration="100" />
<item android:drawable="@drawable/scorepopup4" android:duration="100" />
<item android:drawable="@drawable/invipopup" android:duration="100" />
</animation-list>
ボタンとアニメーション画像のコンテナーの xml は次のとおりです。
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="70dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_margin="5dp">
<ImageView
android:layout_width="35dp"
android:layout_height="35dp"
android:background="@drawable/bd"
android:layout_margin="10dp"
android:onClick="checkGem"
android:contentDescription="bd"/>
<ImageView
android:id="@+id/scorePopup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp" />
</LinearLayout>
checkGem メソッド:
ImageView popup1 = (ImageView) findViewById(R.id.scorePopup);
popup1.setBackgroundResource(R.drawable.popup1_animation);
AnimationDrawable frameAnimation2 = (AnimationDrawable)
popup1.getBackground();
frameAnimation2.start();
私の問題は、アニメーションが一度しか表示されないことですが、クリックするたびにアニメーションを表示したいです。何か案は?