在绘制指南针的指针的时候犯了会晕,指针的旋转在绘制的时候先进行一个角度的旋转,再进行bitmap的绘制。相当于把整个画布进行了旋转。
void android.graphics.Canvas.rotate(float degrees, float px, float py)
public final void
rotate
(float degrees, float px, float py)
Since:
API Level 1
Preconcat the current matrix with the specified rotation.
Parameters
| degrees | The amount to rotate, in degrees |
|---|---|
| px | The x-coord for the pivot point (unchanged by the rotation) |
| py | The y-coord for the pivot point (unchanged by the rotation) |
这里用到的是对中心进行旋转,所以设置下sx和sy为图片的中心位置即可。
另外canvas的几个类似的方法
canvas.scale(sx, sy);
canvas.translate(dx, dy);
另外的一篇绘制圆角http://blog.youkuaiyun.com/pipisky2006/article/details/6160348
本文详细介绍了在Android开发中如何使用Canvas类实现指南针指针的旋转效果,包括通过rotate方法指定旋转角度及旋转中心点,并附带scale和translate方法的使用说明。
7万+

被折叠的 条评论
为什么被折叠?



