安卓 : rotate an image clockwise and anticlockwise with two simple buttons

标签 android image rotation

我有两个简单的按钮和一张图片:

enter image description here

顺时针按钮点击事件==>顺时针旋转图像1度

逆时针按钮点击事件==>将图片逆时针旋转1度

我该怎么做?

最佳答案

image.setRotation(angle)

适用于 API 11 及更高版本。

-编辑 矩阵适用于较低的 API 级别:

顺时针:

Matrix matrix = new Matrix();
imageView.setScaleType(ScaleType.MATRIX);
matrix.postRotate(angle++, image.getDrawable().getBounds().width() / 2, image.getDrawable().getBounds().height() / 2);
image.setImageMatrix(matrix);

对于逆时针,可以将angle++替换为angle--

关于安卓 : rotate an image clockwise and anticlockwise with two simple buttons,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27909652/

相关文章:

android - 监视 Android 服务中的文件夹

android - 更改图像某些部分的颜色

android - Flutter - 如何滚动到 ListView 的底部?

silverlight - 如何为图像控件设置占位符(下载时)?

c++ - 如何在字符串中以圆周运动移动单词?

android - 覆盖后退按钮

android - 在 fragment 中自定义图像

image - 为什么不能对彩色图像进行傅里叶变换?

android - 旋转 Canvas 后坐标计算问题

matlab - 从 3D 数组中提取任意旋转的数据平面作为 2D 数组