amitairos amitairos - 4 months ago 19
Java Question

Repeat AnimationDrawable every few seconds

I have an AnimationDrawable that animates a set of frame images.

How do I implement a restart every 10 seconds?

Thanks.

Neo Neo
Answer

Yes you can, just give your last frame 10 second extra. Example -

    <animation-list xmlns:android="http://schemas.android.com/apk/res/android"  android:oneshot="false">
  <item android:drawable="@drawable/image" android:duration="100" />
  <item android:drawable="@drawable/image1" android:duration="100" />
  <item android:drawable="@drawable/image2" android:duration="100" />
  <item android:drawable="@drawable/image3" android:duration="100" />
  <item android:drawable="@drawable/image4" android:duration="10100" />
 </animation-list>

Hope it will help :)