I use matrix to rotate my image, it's working but i have some problem with new image bitmap. The new bitmap have some space even though I have set the pivot. What should i do to rotate the image but i don't want the space. I use this code below to rotate the bitmap:
Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(), R.drawable.sticker01); int width = bitmapOrg.getWidth(); int height = bitmapOrg.getHeight();
Matrix matrix = new Matrix(); matrix.postRotate(rotate, 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 & height = WRAP_CONTENT
Rotate 0 degree:
Rotate 10 degree: It has space around the real image..
Rotate 50 degree: It has space around the real image (even bigger space)..