I have animationdrawable I want to but same animationdrawable in two imageview. The problem the first do not work and the second work.
AnimationDrawable animation1 = new AnimationDrawable();
Bitmap bitmapba1 = BitmapFactory.decodeResource(getResources(),R.drawable.a);
Bitmap bitmapba2 = BitmapFactory.decodeResource(getResources(), R.drawable.b);
bitmapba1=Bitmap.createScaledBitmap(bitmapba1,x,x,false);
bitmapba2=Bitmap.createScaledBitmap(bitmapba2,x,x,false);
animation1.addFrame(new BitmapDrawable(bitmapba1), 20);
animation1.addFrame(new BitmapDrawable(bitmapba2), 20);
myimage1.setImageDrawable(animation1);
myimage2.setImageDrawable(animation1);
The problem solved but inefficient (primitive) I declared second animation2 same bitmapba1 and bitmapba2 : animation2.addFrame(...(bitmapba1), 20), and animation2.addFrame(...(bitmapba2), 20).
The question is what to do if there are 100 imageview they share same one animationdrawable?