AnimationDrawable Size Scaling

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;)

+4
source share
1 answer

Instead of populating an ImageView, place the image inside the layout and pad in the layout.

+1
source

Source: https://habr.com/ru/post/1398204/


All Articles