Since you are using a Theme.MaterialComponents.*
theme the default background color of the Button
(which is replaced by a MaterialButton
) is the colorPrimary
defined in your app theme.
In your case:
<item name="colorPrimary">@color/purple_500</item>
You can change this value (but this will affect all widgets).
If you want to change globally the button style in your app you can also add the materialButtonStyle
attribute in your app theme:
<style name="Theme.HangmanGame" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<item name="materialButtonStyle">@style/Widget.App.Button</item>
</style>
with:
<style name="Widget.App.Button" parent="Widget.MaterialComponents.Button">
<item name="backgroundTint">@color/...</item>
</style>
If you want to change this color only in the button you can use also the app:backgroundTint
attribute removing the android:background
attribute:
<Button
app:backgroundTint="@color/..."/>
If you want to use a custom background using the android:background
attribute you have to add app:backgroundTint="@null"
to avoid that the button is tinted.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…