アプリケーションに AnimationDrawable を実装する際に問題が発生しています。開発者ガイドを参考にアニメーションを実装しました。何らかの理由で、アニメーションの再生後、最初と最後のフレームが画面に表示されたままになります。
私のxmlファイルは次のようになります。
<animation-list android:id="@+id/selected"
android:oneshot="true" xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/bubbles_1hd" android:duration="50" />
<item android:drawable="@drawable/bubbles_2hd" android:duration="50" />
<item android:drawable="@drawable/bubbles_3hd" android:duration="50" />
<item android:drawable="@drawable/bubbles_4hd" android:duration="50" />
<item android:drawable="@drawable/bubbles_5hd" android:duration="50" />
<item android:drawable="@drawable/bubbles_6hd" android:duration="50" />
<item android:drawable="@drawable/bubbles_7hd" android:duration="50" />
<item android:drawable="@drawable/bubbles_8hd" android:duration="50" />
私のコードは次のようになります。
ImageView img = (ImageView)findViewById(R.id.imageAnimation);
img.setBackgroundResource(R.drawable.bubble_animation);
AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground();
frameAnimation.setOneShot(true);
frameAnimation.start();
私が理解できた唯一の解決策。ImageView を非表示にするアニメーションの最後に設定された遅延タイマーを実装することになります。しかし、私が見逃している、よりシンプルでエレガントなソリューションがあることを望んでいました。
ご協力いただきありがとうございます