如何在 Canvas 上绘制文本,如下图以 Green rectangle
突出显示。
我已经完成了以下代码....但从这段代码我可以直接
编写文本。不能以角度
书写文字。
Bitmap bmpLayered = Bitmap.createBitmap(bmpMain.getWidth(), bmpMain
.getHeight(), Bitmap.Config.ARGB_8888);
Canvas cv = new Canvas(bmpLayered);
Paint charPaint = new Paint();
charPaint.setAntiAlias(true);
charPaint.setStyle(Paint.Style.FILL);
charPaint.setTextSize(24);
charPaint.setColor(Color.BLACK);
charPaint.setStrokeWidth(3);
cv.drawText("None", 570, 222, charPaint);
请帮我解决这个问题。
谢谢。
最佳答案
cv.save();
cv.rotate(-45, x, y);
cv.drawText("your text here", x, y, paint);
cv.restore();
其中 cv 是对 Canvas 的引用,x 和 y 是您要绘制的点。
关于java - 以一定角度在 Canvas 上绘制文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11245253/