Android的可旋转的ImageView [英] Android Rotatable ImageView

查看:504
本文介绍了Android的可旋转的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方法的参数(第二和第三 - 枢轴点)进行变化都没有。即使是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.

我该怎么办呢? :/

How do I do that? :/

推荐答案

您可以通过使用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 编辑:我不得不缩短由于链路)的网址,一些浏览器不喜欢

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆