【问题标题】:How to clip ImageView at the angle degree?如何以角度剪辑ImageView?
【发布时间】:2021-02-23 15:39:50
【问题描述】:

ImageView如何裁剪角度?

点赞:

【问题讨论】:

    标签: android imageview android-imageview degrees


    【解决方案1】:

    通过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)
    }
    

    【讨论】:

      猜你喜欢
      • 2019-04-20
      • 1970-01-01
      • 1970-01-01
      • 2016-08-03
      • 1970-01-01
      • 2022-12-16
      • 2018-08-03
      • 2020-06-29
      • 2022-06-10
      相关资源
      最近更新 更多