AnimationDrawable is not working on 2.3.6 android version.
Is there support library for older verions?
My code is:
iv = (ImageView) findViewById(R.id.splashnew);
BitmapDrawable f0 = (BitmapDrawable)getResources().getDrawable(R.drawable.s1);
BitmapDrawable f1 = (BitmapDrawable)getResources().getDrawable(R.drawable.s2);
BitmapDrawable f2 = (BitmapDrawable)getResources().getDrawable(R.drawable.s3);
int dur = 850;
AnimationDrawable ad = new AnimationDrawable();
ad.addFrame(f0, dur);
ad.addFrame(f1, dur);
ad.addFrame(f2, dur);
ad.start();
ad.setOneShot(true);
I got the answer:
You should start the animation in a runnable.
iv.post(new Runnable(){
public void run(){
ad.start();
ad.setOneShot(true); // use this if you want to run the animation only once
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With