3

我想在画布上画两个彩色圆圈。一切都是正确的,但圈子并不顺利。这是效果:

这是效果

这是代码:

private void drawCircle(Canvas c)
{
    RectF oval = new RectF(20, 20, 100, 100);

    c.drawArc(oval, -90, 180, false, getPaintWithColor(R.color.background));
    c.drawArc(oval, 90, 180, false, getPaintWithColor(R.color.font_grey));
}

private Paint getPaintWithColor(int colorId){
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setDither(true);
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(4);
    paint.setColor(getResources().getColor(colorId));

    return paint;
}
4

1 回答 1

3
paint.setFlags(Paint.ANTI_ALIAS_FLAG)

请参阅Can I draw with antialiasing on canvas?

于 2014-04-25T16:50:17.850 回答