我可以在画布上使用抗锯齿画画吗?

Suz*_*ioc 50 graphics android antialiasing android-canvas

我可以在画布上使用抗锯齿进行绘制吗?

我需要我的圆圈和线条有光滑的边缘.

Ale*_*tin 83

绘图操作需要Paint.在这Paint你设置Paint.setFlags(Paint.ANTI_ALIAS_FLAG)

  • 您可以按照Arun Chettoor的建议使用`mPaint.setAntiAlias(true);`代替 (2认同)

Aru*_*oor 23

看一下这个.它相当使用光滑的边缘.. http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/FingerPaint.html

获得抗锯齿所需的绘制属性是:

     mPaint = new Paint();
     mPaint.setAntiAlias(true);
Run Code Online (Sandbox Code Playgroud)

用于绘图用途:

     mPath = new Path();
     mPath.reset();
     mPath.moveTo(x, y);//can be used where to trigger the path
Run Code Online (Sandbox Code Playgroud)

onDraw方法应该包含:

     canvas.drawPath(mPath, mPaint);
Run Code Online (Sandbox Code Playgroud)

将mPath和mPaint声明为全局.