3

I want to draw two colored circle on canvas. Everything is right but the circle isn't smooth. This is the effect:

This is the effect

And this is code:

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;
}
sennin
  • 8,552
  • 10
  • 32
  • 47

1 Answers1

3
paint.setFlags(Paint.ANTI_ALIAS_FLAG)

See in Can I draw with antialiasing on canvas?

Community
  • 1
  • 1
Victor Pinto
  • 447
  • 7
  • 8
  • I tried both this solution as well as `Paint.setAntiAlias(true)` (separately and together) and it makes no difference on my `SweepGradient`. Any other ideas? – mbm29414 Jan 06 '17 at 01:54