@Override
public void onDraw(Canvas canvas) {
//This saves off the matrix that the canvas applies to draws, so it can be restored later.
canvas.save();
//now we change the matrix
//We need to rotate around the center of our text
//Otherwise it rotates around the origin, and that's bad.
float py = this.getHeight()/2.0f;
float px = this.getWidth()/2.0f;
canvas.rotate(180, px, py);
//draw the text with the matrix applied.
super.onDraw(canvas);
//restore the old matrix.
canvas.restore();
}
本文介绍了一种使用Android Canvas进行180度旋转绘制的方法。通过保存和恢复Canvas状态、设置旋转中心点实现文字等内容的旋转显示。
784

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



