I am having issues implementing an AnimationDrawable in my application. I referenced the developer guide to implement the animation. For whatever reason, after the animation plays, the first and last frame remain visible on the screen.
My xml file looks like this:
<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" />
and my code looks like this:
ImageView img = (ImageView)findViewById(R.id.imageAnimation);
img.setBackgroundResource(R.drawable.bubble_animation);
AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground();
frameAnimation.setOneShot(true);
frameAnimation.start();
The only solution I have been able to figure out. Would be to implement a delayed timer set for the end of the animation that hides the ImageView. However I was hoping that there is a simpler more elegant solution that I am missing.
Thanks for your help
The solution that I found for this is to insert a transparent image for the first and last slide of the drawable. Not sure if this is the best approach but it works.