I use the matrix to rotate the image, it works, but I have a problem with the new bitmap. The new bitmap has some space, although I installed a support element. What should I do to rotate the image, but I do not want space. I use this code below to rotate a bitmap:
Bitmap bitmapOrg = BitmapFactory.decodeResource (getResources (), R.drawable.sticker01); int width = bitmapOrg.getWidth (); int height = bitmapOrg.getHeight ();
Matrix matrix = new matrix (); matrix.postRotate (rotation, width / 2, height / 2);
Bitmap resizedBitmap = Bitmap.createBitmap (bitmapOrg, 0, 0, width, height, matrix, true); BitmapDrawable bmd = new BitmapDrawable (resizedBitmap);
imageView.setBackgroundColor (Color.white); imageView.setImageDrawable (BMD); imageView.setScaleType (ScaleType.FIT_XY);
imageView -> width and height = WRAP_CONTENT
Rotate 0 degrees: 
10 degree rotation:
It has a space around the real image.
50 degree rotation:
It has a space around the real image (even larger space).
source share