3
我制作了一组3个图像,代表动物的移动。每个图像代表一个框架,并且只包含具有透明背景的动物。Android Imageview with AnimationDrawable来源更改大小
我已经在代码中AnimationDrawable并创建了动画:
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);
我设置动画作为一个ImageView的背景并启动它
imgAnimal.setBackgroundDrawable(staticAnimation); staticAnimation.start()
因为框架具有不同的宽度(绘图需要重新创建步骤移动)看起来像Imageview调整动画中的图像大小。更好的说,如果frame1比frame2大,那么frame1显示正常,但frame2被拉伸到与frame1一样大。看起来真的很糟糕。
有关如何阻止此行为的任何建议?谢谢。