【问题标题】:Android canvas circle color blurAndroid画布圆圈颜色模糊
【发布时间】:2013-12-05 12:49:56
【问题描述】:

我想用视图类在画布上画一个圆(它更多,但我对圆有问题)。

我从这个链接开始:http://mindtherobot.com/blog/272/

onMeasure() 函数是相同的,我正在缩放相同。在我的模拟器和 Nexus 7 上,一切看起来都很完美,但在我的 LG 上却不是

看起来圆圈的颜色模糊了。

代码是:

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);
}

【问题讨论】:

    标签: android view android-canvas draw


    【解决方案1】:

    使用 Paint 的 AntiAlias 属性。它可以防止图像模糊并提供平滑边缘

    debug = new Paint();
    debug.setAntiAlias(true);
    debug.setColor(Color.RED);
    

    【讨论】:

    • 感谢您的回答,矩形看起来好多了。问题是它对我的圈子没有影响。但它只在我的手机上。在每个模拟器上都不是。问题可能出在手机上吗
    猜你喜欢
    • 1970-01-01
    • 2011-07-25
    • 2016-11-14
    • 1970-01-01
    • 2016-10-10
    • 2017-03-16
    • 1970-01-01
    • 1970-01-01
    • 2015-11-28
    相关资源
    最近更新 更多