I want to make the corners of a button
round. Is there an easy way to achieve this in Android?
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: