rotation()
и alpha()
ViewPropertyAnimator, чтобы сделать это.Проверьте этот код:
boolean isImage1Showing = true;
//onClick() method for the 2 ImageView(s)
public void fadeAndRotate(View view){
if (isImage1Showing){
//Rotate the resource on 1st ImageView by 360 degrees
imageViewA.animate().rotation(360f).setDuration(2000);
imageViewA.animate().alpha(0).setDuration(2000);
//Displaying the other image on to the screen
imageViewB.animate().alpha(1).setDuration(2000);
isImage1Showing = false;
} else {
isImage1Showing = true;
imageViewB.animate().rotation(360f).setDuration(2000);
//Displaying the previous image
imageViewA.animate().alpha(1).setDuration(2000);
//fading out the currently displayed image
imageViewB.animate().alpha(0).setDuration(2000);
}
}
Использовать
.rotationBy(float value)
метод вместо
.rotation(float value)
метод. В вашем случае это вращается 360f, но вы хотите, чтобы повернуть BY 360f.
Так что этот код должен работать:
imageViewA.animate().rotationBy(360f).setDuration(2000);