1

So I have been trying to find a way to make a MaterialButton from the Material Components library have perfectly rounded corners. What I mean by this is effectively they have a corner size of 50% the height of the button.

In some of the documentation it indicates that this should be possible with the quote below.

Shape size can be determined using a value that is either absolute or a percentage.

I have a couple of working solutions, firstly measuring the view and setting the corner size that way, but then I discovered that the ExtendedFloatingActionButton uses a RelativeCornerSize object.

However, I still cannot find a solution in XML.

dreamcrash
  • 40,831
  • 24
  • 74
  • 100
Henry Twist
  • 5,298
  • 3
  • 17
  • 41

2 Answers2

1

You can use the shapeAppearanceOverlay attribute.

<com.google.android.material.button.MaterialButton
    app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.Button.50"
    .../>

with:

  <style name="ShapeAppearanceOverlay.Button.50" parent="">
    <item name="cornerFamily">rounded</item>
    <item name="cornerSize">50%</item>
  </style>

You can use an absolute or a percentage value.

enter image description here

Gabriele Mariotti
  • 250,295
  • 77
  • 670
  • 690
0

There are specific commands with Material Design.

I could not explain it better than this answer

It works with Android Studio 3.1 or higher

codearn19
  • 136
  • 9