0

I want to draw a circle (it is more but I have problems with the circle) on a canvas with the View Class.

I have started with this link: http://mindtherobot.com/blog/272/

The onMeasure() function is the same and I am scaling the same. In my emulator and on my Nexus 7 everything looks perfect but on my LG it isn´t

It looks loke the color of the circle is blurred.

The code is:

protected void onDraw(Canvas canvas) {

    float scale = (float) getWidth();
    canvas.save(Canvas.MATRIX_SAVE_FLAG);
    canvas.scale(scale, scale);
    drawCircle(canvas);
    canvas.restore();
}


private void drawCircle(Canvas canvas) {

    canvas.save(Canvas.MATRIX_SAVE_FLAG);
    canvas.drawOval(rimRect, debug);
        canvas.restore();
}
private void initDrawingTools() {
    float O1x = -0.5f;
    float O1y = -0.5f;
    float O2x = 0.5f;
    float O2y = 0.5f;


    rimRect = new RectF(O1x, O1y, O2x, O2y);

    debug = new Paint();
    debug.setColor(Color.RED);
}
Cœur
  • 37,241
  • 25
  • 195
  • 267

1 Answers1

0

use AntiAlias property for Paint. it protect the image from blurring and gives smoothing edges

debug = new Paint();
debug.setAntiAlias(true);
debug.setColor(Color.RED);
Gopal Gopi
  • 11,101
  • 1
  • 30
  • 43
  • Thanks for the answer the rectangle looks much better.The Problem is taht it hast no effect on my circle. But it only is on my Phone. On every emulator it isn´t. Could the problem be something with the Phone – user2709105 Dec 06 '13 at 16:43