我通過使用重新縮放畫布更大的矩形(100×100)的輔助功能進行管理,繪製圓和規模在畫布到原來的大小。
public static void drawOval(Canvas canvas, RectF rectangle, Paint paint, float scale) {
float originalStrokeWidth = paint.getStrokeWidth();
float upScaling = 100f;
paint.setStrokeWidth(originalStrokeWidth * upScaling);
canvas.save();
RectF newRect = new RectF();
newRect.left = rectangle.left*upScaling;
newRect.top = rectangle.top*upScaling;
newRect.right = rectangle.right*upScaling;
newRect.bottom = rectangle.bottom*upScaling;
canvas.scale(scale/upScaling, scale/upScaling);
canvas.drawOval(newRect, paint);
canvas.restore();
paint.setStrokeWidth(originalStrokeWidth);
}
public static void drawOval(Canvas canvas, RectF rectangle, Paint paint) {
drawOval(canvas, rectangle, paint, 1f);
}
所以,在這裏我不得不canvas.drawOval(RECT,油漆)我 CanvasUtils.drawOval(帆布,矩形,油漆)取代它;
我已經注意到,「錯誤」當我使用位圖作爲畫布繪製圖作爲計的背景下才會發生。