1

I have two simple buttons and one image:

enter image description here

clockwise button click event ==> rotates the image 1 degree in clockwise

anticlockwise button click event ==> rotates the image 1 degree in anticlockwise

how can I do that?

jack peterson
  • 287
  • 1
  • 2
  • 14
  • Try this link http://stackoverflow.com/questions/3045832/how-can-i-use-rotateanimation-to-rotate-a-circle/14297097#14297097 – Krish Jan 12 '15 at 19:56

1 Answers1

1
image.setRotation(angle)

works for API 11 and above.

-Edit Matrix works for lower API levels:

for clockwise:

Matrix matrix = new Matrix();
imageView.setScaleType(ScaleType.MATRIX);
matrix.postRotate(angle++, image.getDrawable().getBounds().width() / 2, image.getDrawable().getBounds().height() / 2);
image.setImageMatrix(matrix);

for anticlockwise, you can replace angle++ to angle--

wO_o
  • 181
  • 3
  • 13
  • its not what I want. for example when user click on clockwise button the angle of image is +1 and by clicking again the angle is +2 , .... . unfortunately I'm developing my app for API level 8 and above. – jack peterson Jan 12 '15 at 20:03