See here: Coloring Buttons in Android with Material Design and AppCompat
To summarize, you can use the tintBackground
attribute on the button itself or you can use colorControlNormal
(or a combination).
Also, you can just use Button
and it'll get converted to an AppCompatButton
as long as you're using the theme and inheriting from AppCompatActivity
correctly.
Examples from the linked URL
theme.xml:
<item name="colorButtonNormal">@color/button_color</item>
v21/theme.xml
<item name="android:colorButtonNormal">@color/button_color</item>
or
<Button
android:id="@+id/add_remove_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="@color/bg_remove_btn_default"
android:textColor="@android:color/white"
tools:text="Remove" />