我想在RelativeLayout中多次orate一次ImageView。 为此,我使用:
angleRotation = angleRotation + (float)90;
Rect bounds = imgToRotate.getDrawable().getBounds();
Matrix matrix=new Matrix();
imgToRotate.setScaleType(ScaleType.MATRIX); //required
matrix.postRotate((float) angleRotation, bounds.width() / 2 , bounds.height() / 2);
imgToRotate.setImageMatrix(matrix);
问题是我使用的矩阵会改变我的ImageView的大小。我不知道怎么不改变大小。
有任何帮助吗?非常感谢你。
答案 0 :(得分:0)
难道你不能简单地使用xml文件来创建旋转动画吗? http://developer.android.com/guide/topics/resources/animation-resource.html
答案 1 :(得分:0)
这是我在我的一个应用程序中使用的代码,用于根据位图旋转图像。
Matrix mtx = new Matrix();
mtx.preRotate(90);
Bitmap rotatedBitmap = Bitmap.createBitmap(originalBitmap, 0, 0, w, h, mtx, true);
之后,您可以将图像位图设置为imageView。 我假设您可以保留(或获取)对原始位图的引用。
编辑: 如果您的目标是API 11及更高版本,则可以使用方法:
View.setRotation(float angle);
希望它有所帮助。