mpellegr mpellegr - 11 months ago 33
Android Question

Rotating ImageView changes where paddingBottom is

When I call ImageView.setRotation() I'm able to rotate the view but the paddingBottom attribute is now no longer working on the bottom of the newly rotated view but the bottom before it was rotated. Is there any way to rotate a view and have the paddingBottom, etc, attributes rotate with it? Or is there a way I can find where the new "bottom" of the view is?


I was able to do what I needed by rotating the bitmap itself for the image using a matrix. This rotates the source image but not the ImageView, so paddingBottom remained at the bottom.

Bitmap bitmap = ((BitmapDrawable)myImageView.getDrawable()).getBitmap();
Matrix matrix = new Matrix();
Bitmap rotatedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);