Question

I've got a strange problem with setting the transparency (alpha) of an image that's also being animated with the RotateAnimation class. On all API levels up to 16 (JB) the combined fading and animation works fine. On API 16+, fading the animated image resets the animation.

I'm supporting API level 9 and up.

Up to API level 16, I use:

ivDial.setAlpha(iOverlayAlpha);

where iOverlayAlpha is an int. All good so far. For API level 16+, setAlpha(int) is deprecated, so I have to use:

ivDial.setImageAlpha(iOverlayAlpha);

But this resets the animation. I can force the animation to run again, but it keeps getting reset every time I call setImageAlpha(iOverlayAlpha).

I could use:

ivDial.setImageAlpha(fOverlayAlpha);

where fOverlayAlpha is a float. This works OK, and doesn't reset the animation, but the documentations says "Note that setting alpha to a translucent value (0 < alpha < 1) can have significant performance implications, especially for large views."

My view isn't very large, but I have a number of them visible at the same time, so I don't want to kill performance with this.

Does anybody know why the animation is being reset with SetImageAlpha(int) in JB?

Thanks.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top