How to make the corners of a button round?

前端 未结 13 934
暖寄归人
暖寄归人 2020-11-22 16:36

I want to make the corners of a button round. Is there an easy way to achieve this in Android?

13条回答
  •  Happy的楠姐
    2020-11-22 17:39

    Is there an easy way to achieve this in Android?

    Yes, today there is, and it is very simple.
    Just use the MaterialButton in the Material Components library with the app:cornerRadius attribute.

    Something like:

        
    

    It is enough to obtain a Button with rounded corners.

    You can use one of Material button styles. For example:

    
    

    Also starting from the version 1.1.0 you can also change the shape of your button. Just use the shapeAppearanceOverlay attribute in the button style:

      
    
      
    

    Then just use:

    
    

    You can also apply the shapeAppearanceOverlay in the xml layout:

    
    

    The shapeAppearance allows also to have different shape and dimension for each corner:

    
    

提交回复
热议问题