How do I antialias the clip boundary on Android's canvas?

前端 未结 4 1479
小蘑菇
小蘑菇 2021-01-30 09:30

I\'m using Android\'s android.graphics.Canvas class to draw a ring. My onDraw method clips the canvas to make a hole for the inner circle, and then draws the full outer circle o

4条回答
  •  情歌与酒
    2021-01-30 09:47

    I too had this same problem. I tried using Bitmap masking (xFermode) to fix the Aliasing, but it was heavy.

    So for API < 19, I used the Bitmap masking way and for API >= 19, I used Path.Op. Instead of clipping the path and then drawing the shape. I did a REVERSE_DIFFERENCE of the path and the shape(which is of type Path). You can perform operations on Path from API 19 and above.

    Works perfectly for me!

提交回复
热议问题