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() {
@Override
public void run() {
rC1.setBackgroundResource(R.drawable.coinb);
rC1.animate().setDuration(500).rotationYBy(90f);
}
});
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: https://ibb.co/48W2Xjh
animation: https://i.ibb.co/pftWYwz/315774853-505872868270345-6007333826531395103-n.gif
I checked all other functions etc. to check if anything can overwrite it, but none connects with it.
CodePudding user response:
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);