Buttons
The following classes implement a button:
- Button
- AppCompatButton
- MaterialButton
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/loginButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/space"
android:text="@string/auth_login"
android:textAllCaps="false"
android:textStyle="bold"
android:textSize="18sp"
android:textColor="..."
android:textAlignment="..."
...
/>
You can add an icon on either side of the text
<androidx.appcompat.widget.AppCompatButton
android:drawableStart="@drawable/ic_home_black_24dp"
android:drawableTint="@color/light_blue_600"
android:drawableTintMode="src_over"
android:drawablePadding="@dimen/space2x"
...
/>
MaterialButton
This class supplies updated Material styles for the button in the constructor.
All attributes from com.google.android.material.R.styleable#MaterialButton are supported.
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 (outline) buttons, this class uses ?attr/colorPrimary for the text color and transparent for the background tint.
As you see MaterialButton manages its own background drawable, so do not use the android:background attribute. You need change your theme.
Attributes to style the icon inside the button:
- app:icon
- app:iconPadding
- app:iconTint
- app:iconTintMode
- app:iconGravity
Attributes to style the button:
- app:backgroundTint
- app:backgroundTintMode
- app:rippleColor
- app:strokeColor
- app:strokeWidth
- app:cornerRadius - specifies the radius of all four corners
Also you can use Button or AppCompatButton with material theme.