-2

I want something like this. When someone clicks the button it should rotate it in 90 degrees perfectly.

Gangaraju
  • 4,406
  • 9
  • 45
  • 77

1 Answers1

1

First Rotate your bitmap to 90 degree and then assign it again to your imageView.

Try following code:

In your onCreate Method,

myImageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            myImageView.setImageBitmap(RotateBitmap(((BitmapDrawable)myImageView.getDrawable()).getBitmap() , 90));
        }
    });

And Create a Method below.

public static Bitmap RotateBitmap(Bitmap source, float angle) {
        Matrix matrix = new Matrix();
        matrix.postRotate(angle);
        return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true);
}
Shaishav Jogani
  • 2,111
  • 3
  • 23
  • 33