4

How to clip ImageView at the angle degree?

Like: this

Dr Mido
  • 2,414
  • 4
  • 32
  • 72
imworse
  • 51
  • 4

1 Answers1

0

Found a solution via path.arcTo and canvas.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)
}
imworse
  • 51
  • 4