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

前端 未结 4 1491
小蘑菇
小蘑菇 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:35

    As far as I know, you can't antialias clip regions.

    I'd suggest using bitmap masking instead. Render the the pink, white, and light gray foreground to one bitmap, render the outer/inner circle mask (the grayscale alpha channel) to another bitmap, and then use Paint.setXfermode to render the foreground bitmap with the mask as its alpha channel.

    An example can be found in the ApiDemos source code here.

提交回复
热议问题