flavioarfaria / KenBurnsView

Android ImageViews animated by Ken Burns Effect
Apache License 2.0
2.73k stars 435 forks source link

Pausing the KenBurnsView animaiton makes the image inside too small #26

Closed aritraroy closed 8 years ago

aritraroy commented 9 years ago

When the animation plays, its perfectly fine. But when I use view.pause() then the animations stops but the image becomes very small in size.

How can this problem be solved? I need to give the users a way to stop the animation of this View if they want to.

flavioarfaria commented 9 years ago

Did you try the sample app? That's not happening. Could you provide steps to reproduce it?

aritraroy commented 9 years ago

This is my XML

<com.flaviofaria.kenburnsview.KenBurnsView
                android:id="@+id/nav_header_cover"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:src="@drawable/cover_1" />

This is how I set the drawable programatically,

Drawable drawable = Drawable.createFromPath(fileName.getAbsolutePath());
navHeader.setImageDrawable(drawable);

This is how I am playing/pausing it,

if (isAnimOn)
navHeader.resume();
else
navHeader.pause();

Can you please point out what is the mistake here?

aritraroy commented 9 years ago

I have tried a lot, but still have the problem. Any help?

Pkmmte commented 8 years ago

I used to have this issue when specifying CENTER_CROP as the scale type. Removing it solved the issue for me.

Strange because, according to the KenBurnsView.java source, .setScaleType() is not supposed to do anything.

EDIT: I still kept getting it when using Picasso to load images into a KenBurnsView. However, the issue went away when loading a bitmap into the KenBurnsView directly instead of letting Picasso do it. I think it may have something to do with drawable bounds. Try to see if setImageBitmap() fixes your issue.