Material Button
A convenience class for creating a new Material button.
This class supplies updated Material styles for the button in the constructor. The widget will display the correct default Material styles without the use of the style flag.
All attributes from com.google.android.material.R.styleable#MaterialButton are supported. Do not use the android:background attribute. MaterialButton manages its own background drawable, and setting a new background means MaterialButton can no longer guarantee that the new attributes it introduces will function properly. If the default background is changed, MaterialButton cannot guarantee well-defined behavior.
For filled buttons, this class uses your theme's ?attr/colorPrimary for the background tint color and ?attr/colorOnPrimary for the text color. For unfilled buttons, this class uses ?attr/colorPrimary for the text color and transparent for the background tint.
Add icons to the start, center, or end of this button using the app:icon,
app:iconPadding, app:iconTint, app:iconTintMode and app:iconGravity attributes.
If a start-aligned icon is added to this button, please use a style like one of the ".Icon" styles specified in the default MaterialButton styles. The ".Icon" styles adjust padding slightly to achieve a better visual balance. This style should only be used with a start-aligned icon button. If your icon is end-aligned, you cannot use a ".Icon" style and must instead manually adjust your padding such that the visual adjustment is mirrored.
Specify background tint using the app:backgroundTint and
app:backgroundTintMode attributes, which accepts either a color or a color state list.
Ripple color / press state color can be specified using the app:rippleColor attribute. Ripple opacity will be determined by the Android framework when available. Otherwise, this color will be overlaid on the button at a 50% opacity when button is pressed.
Set the stroke color using the app:strokeColor attribute, which accepts either a color or a color state list. Stroke width can be set using the app:strokeWidth attribute.
Specify the radius of all four corners of the button using the app:cornerRadius attribute.
For more information, see the component developer guidance and design guidelines.