Skip to content

ImageView background change while .animate() [Java][Android Studio]

I’m trying to do some ‘nice’ animation during rotation of the image. I mean, I’m trying to change image bacground while the rotation reach 90f (is totally invisible), to continue rotation with other src.

In this test case, I’m trying to rotate chest image and end the animation with coin image.

rC1 is obviously an ImageView

rC1.animate().setDuration(500).rotationYBy(90f).withEndAction(new Runnable() {
    public void run() {

And well, it works, because the animation starts, then ending with invisible chest 90f and then it appears with both images – chest and coin like this:


I checked all other functions etc. to check if anything can overwrite it, but none connects with it.



An ImageView can both have a source image and a background image. I am guessing you are adding a background image and not changing the source image or vice versa. Try changing rC1.setBackgroundResource(R.drawable.coinb); to rC1.setImageResource(R.drawable.coinb);

User contributions licensed under: CC BY-SA
1 People found this is helpful