旋转 ImageView 会改变 paddingBottom 所在的位置
Rotating ImageView changes where paddingBottom is
当我调用 ImageView.setRotation() 时,我可以旋转视图,但 paddingBottom 属性现在不再作用于新旋转视图的底部,而是作用于旋转前的底部。有什么方法可以旋转视图并让 paddingBottom 等属性随之旋转吗?或者有什么方法可以找到视图的新 "bottom" 在哪里?
我能够通过使用矩阵为图像旋转位图本身来完成我需要的操作。这会旋转源图像而不是 ImageView,因此 paddingBottom 保留在底部。
Bitmap bitmap = ((BitmapDrawable)myImageView.getDrawable()).getBitmap();
Matrix matrix = new Matrix();
matrix.postRotate(rotation);
Bitmap rotatedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
myImageView.setImageBitmap(rotatedBitmap);
当我调用 ImageView.setRotation() 时,我可以旋转视图,但 paddingBottom 属性现在不再作用于新旋转视图的底部,而是作用于旋转前的底部。有什么方法可以旋转视图并让 paddingBottom 等属性随之旋转吗?或者有什么方法可以找到视图的新 "bottom" 在哪里?
我能够通过使用矩阵为图像旋转位图本身来完成我需要的操作。这会旋转源图像而不是 ImageView,因此 paddingBottom 保留在底部。
Bitmap bitmap = ((BitmapDrawable)myImageView.getDrawable()).getBitmap();
Matrix matrix = new Matrix();
matrix.postRotate(rotation);
Bitmap rotatedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
myImageView.setImageBitmap(rotatedBitmap);