I made a set of three images that will represent the movement of the animal. Each image is a frame and consists only of an animal with a transparent background.
I made an AnimationDrawable in code and created an animation:
AnimationDrawable staticAnimation = new AnimationDrawable ();
staticAnimation.addFrame (ctx.getResources (). getDrawable ("frame1"), 150);
staticAnimation.addFrame (ctx.getResources (). getDrawable ("frame2"), 150);
staticAnimation.addFrame (ctx.getResources (). getDrawable ("frame3"), 150);I set the animation as background for Imageview and run it
imgAnimal.setBackgroundDrawable (staticAnimation);
staticAnimation.start ()
Since frames have different widths (the drawing should recreate the movement steps), it seems that Imageview resizes images in the animation. Better to say, if frame1 is larger than frame2, frame 1 is displayed normally, but frame 2 is stretched so that it is equal to frame1. It looks very awful.
Any suggestions on how to stop this behavior? Thank.
source
share