android - Arc on canvas 没有抗锯齿

标签 android surfaceview

我想在 Canvas 上画两个彩色圆圈。一切正常,但圆圈并不光滑。 这是效果:

This is the effect

这是代码:

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

最佳答案

paint.setFlags(Paint.ANTI_ALIAS_FLAG)

参见Can I draw with antialiasing on canvas?

关于android - Arc on canvas 没有抗锯齿,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19496377/

相关文章:

android - 点击饼图上的事件 - mpandroid

Android、启动器和最喜欢的应用程序

android - 开始录制后相机变暗

android - 自定义相机安卓

android - Android 中 SurfaceView 的 3D 转换?

相机预览顶部的 Android 按钮

android - 在 Nexus S 4G 上打开/关闭 4g

java - 为什么手势监听器不起作用?

android - 如何在页面android布局的底部和中心放置一个 View ?

Android 相机 - 我们可以从全屏中截取图像的一部分吗