如果您使用画布进行绘图(在您的情况下应该如此),这实际上非常简单.
鉴于您知道图像应该旋转的点的坐标,您可以这样做:
private void doDraw(Canvas canvas) {
canvas.save();
float px = ...;
float py = ...;
canvas.rotate(degrees, px, py);
arrow.draw(canvas);
canvas.restore();
}
Run Code Online (Sandbox Code Playgroud)
degrees将是一个整数值,当用户单击L或R按钮时,您可以递增/递减.canvas.rotate照顾其余的!
您必须在 android 中使用 3d 旋转来处理动画,并尝试使用矩阵旋转......我有这方面的位图代码......
Bitmap bmp=BitmapFactory.decodeResource(getResources(), R.drawable.bar);
Matrix mtx = new Matrix();
mtx.postRotate(180); // rotating 180 degrees clockwise
Bitmap rotatedBMP = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth() ,bmp.getHeight() , mtx, true); // creating the bitmap image with new angle
Run Code Online (Sandbox Code Playgroud)
还要检查这个
| 归档时间: |
|
| 查看次数: |
9841 次 |
| 最近记录: |