I'm trying to animate some png and i would loop the animation. This is my code:
wave.setBackgroundResource(R.drawable.wave_animation);
frameAnimation = (AnimationDrawable)wave.getBackground();
frameAnimation.setCallback(wave);
frameAnimation.setVisible(true, true);
frameAnimation.start();
and here the xml with the png
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="true">
<item android:drawable="@drawable/wave_01" android:duration="200" />
<item android:drawable="@drawable/wave_02" android:duration="200" />
<item android:drawable="@drawable/wave_03" android:duration="200" />
<item android:drawable="@drawable/wave_04" android:duration="200" />
</animation-list>
I added also the android:oneshot=false but doesn't work.
This is running an animation on image. Before starting the animation you need to make sure its not already running. Add a check before starting animation, if its running then stop it and then start it.
img_animation.xml // Check for comments in below