如何以角度裁剪ImageView?

How to clip ImageView at the angle degree?

如何在角度裁剪ImageView?

赞:

通过 path.arcTocanvas.clipPath 找到解决方案。

private val oval = RectF()
override fun onDraw(canvas: Canvas) {

    val x = width/2f
    val y = height/2f
    val radius = width/2f

    oval.left = x - radius
    oval.top = y - radius
    oval.right = x + radius
    oval.bottom = y + radius

    val path = Path()
    path.moveTo(x,y)
    path.arcTo(oval, startAngle, sweepAngle)
    path.close()

    canvas.clipPath(path);
    super.onDraw(canvas)
}