Android: RoundRectShape: Modify corner radii

后端 未结 1 426
走了就别回头了
走了就别回头了 2020-12-22 07:25

I have a RoundRectShape that is drawn in a View\'s onDraw() function.

The corners of this shape are modified by any drag acti

相关标签:
1条回答
  • 2020-12-22 07:52

    I think you don't need to use RoundRectShape at all. RoundRectShape is immutable so the only way to change its values is to use reflection. You can easily accomplish the same drawnings by calling Canvas.drawRoundRect(RectF rect, float rx, float ry, Paint paint) method directly without using RoundRectShape. Or you can look at RoundRectShape implementation and just use its code in your onDraw() method.

    EDIT: The comments about RoundRectShape not being the right way to go and looking at the implementation were right. Following the implementation found a call to:

    mPath.addRoundedRect() 
    

    which has a variation allowing a float of corner radii as the input (Path.addRoundRect)

    In answering the question:

    Use a path instead of a shape as the variable and draw the new Rounded Rectangle to the path when necessary

    0 讨论(0)
提交回复
热议问题