Android可旋转ImageView [英] Android Rotatable ImageView
问题描述
我想创建一个可旋转的ImageView,我将指定一定的角度和枢轴点,看到它围绕该枢轴点旋转。我尝试这样:
I am trying to create a Rotatable an ImageView to which I will specify certain angle and pivot point and see it rotated around that pivot point. I tried something like this:
Matrix matrix = new Matrix();
matrix.postRotate(45, imageView.getWidth(), imageView.getHeight());
imageView.setScaleType(ScaleType.MATRIX);
imageView.setImageMatrix(matrix);
但是postRotate方法的参数(第二个和第三个 - 关键点)使NO NO CHANGE 。即使它们是0,0也是一样的。
but the parameters of postRotate method (the second and third - the pivot points) make NO CHANGE at all. even if they are 0, 0 - it's the same thing.
所以我想创建一个ImageView,在初始化时旋转一定角度。在本例中为45度。我尝试设置边界和工作人员..没有帮助。
So I wanna create a ImageView that would be rotated by certain angle when initialized. In this example 45 degrees. I tried setting the bounds and staff.. no help.
我如何做? :/
推荐答案
可以使用setRotation(int)旋转ImageView;
You can rotate a ImageView by using setRotation(int);
// rotate imageView 45 around center pivot point
imageView.setPivotX(imageView.getWidth()/2);
imageView.setPivotY(imageView.getHeight()/2);
imageView.setRotation(45);
参考: http: /goo.gl/WhhGM
编辑:我不得不缩短链接,因为a)在url,一些浏览器不喜欢这样。
Reference: http://goo.gl/WhhGM I had to shorten the link because of a ) in the url, some browsers don't like that.
这篇关于Android可旋转ImageView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!