And*_*ala 3 animation android canvas
我需要一些帮助,在多个图像中围绕其中心旋转一个图像,这些图像被绘制到android中的画布.
我正在将图像加载到画布,如下所示.
canvas.drawBitmap(mMachineBackground, 0, 0, null);
canvas.drawBitmap(mMachineRotator, 0, 0, null);
Run Code Online (Sandbox Code Playgroud)
我想只围绕轴的中心旋转第二个位图,而不是旋转整个画布(也包括第一个位图).
提前致谢.
您可以围绕中心轴旋转:
Matrix matrix = new Matrix();
//move image
matrix.setTranslate(getXPos() - (imageWidth / 2), getYPos() - (imageHeight / 2));
//rotate image, getXPos, getYPos are x & y coords of the image
matrix.postRotate(angleInDegrees, getXPos() - imageWidth / 2, getYPos() - imageHeight / 2);
//rotatedBMP is the image you are drawing,
canvas.drawBitmap(rotatedBMP, matrix, Paint);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3677 次 |
| 最近记录: |