I have the following problem: in the view, I want to set the animation for ImageView. It works great when I have the layout width and height on "wrap_content". But when I change them to fill_parent or add margin / padding attributes to my ImageView, AnimationDrawable has a different size and is not suitable for the image, despite the animation being displayed.
Is there a way to scale AnimationDrawable with ImageView or another solution for this problem? I think it can be quite simple, but I canβt understand what is going wrong (maybe some kind of problem with bitmap images?).
Here is my code (pretty simple):
private void initAnimation(Bitmap bm) { statusAnim.addFrame(new BitmapDrawable(bm), 300); zoomedImage.setBackgroundDrawable(statusAnim); } @Override public void onWindowFocusChanged(boolean hasFocus) { if (hasFocus) statusAnim.start(); else statusAnim.stop(); }
And xml src animation animation:
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false" > <item android:drawable="@drawable/status_blank" android:duration="300"/>
it would be great if someone helped me solve this problem;)
source share