【问题标题】:Arc on canvas has no antialiasing画布上的弧没有抗锯齿
【发布时间】:2013-10-21 13:49:03
【问题描述】:

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

这是代码:

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

【问题讨论】:

    标签: android surfaceview


    【解决方案1】:
    paint.setFlags(Paint.ANTI_ALIAS_FLAG)
    

    见Can I draw with antialiasing on canvas?

    【讨论】:

    • 我尝试了这个解决方案以及Paint.setAntiAlias(true)(单独和一起),这对我的SweepGradient没有任何影响。还有其他想法吗?
    猜你喜欢
    • 2016-11-03
    • 2011-08-27
    • 1970-01-01
    • 2013-10-31
    • 1970-01-01
    • 2016-04-24
    • 1970-01-01
    • 2011-05-14
    • 2013-03-26
    相关资源
    最近更新 更多