I am developing a game where a user needs to tap on the image in ImageView to rotate it. On each tap image rotates by 90 degrees in clockwise direction. But image is taking
Short method
View.animate().rotation(90).setDuration(0);
I also tried to do it once and couldn't find any other solution but using animation. Here how I'd do.
private void rotate(float degree) {
final RotateAnimation rotateAnim = new RotateAnimation(0.0f, degree,
RotateAnimation.RELATIVE_TO_SELF, 0.5f,
RotateAnimation.RELATIVE_TO_SELF, 0.5f);
rotateAnim.setDuration(0);
rotateAnim.setFillAfter(true);
imgview.startAnimation(rotateAnim);
}
did you try to use a custom view extending imageview and rotating the image in a background thread?
You don't need to rotate the object, rotating the view should be enough. If you are aiming API>=11 you can always do this.
mImageView.setRotation(angle);
Cheers.