Coming from this thread: Android Material Design Button Styles
I couldn't understand how to individually change the colors of the buttons, so that not all buttons are with the same color.
<item name="android:colorButtonNormal">@color/blue</item>
This solution works nice, but it changes the color of all buttons.
In API 22, we can change the color of the different buttons by using the backgroundTint
, like so:
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="3dp"
android:backgroundTint="@color/orange"
android:text="@string/button1_text"
android:textAllCaps="true"
android:textColor="@color/white"
android:textSize="18sp" />
How can we do it in API 21 ?
That's the styles.xml
that I have:
<style name="AppTheme" parent="@android:style/Theme.Material.Light">
<item name="android:actionBarStyle">@style/actionBarCustomization</item>
<item name="android:spinnerDropDownItemStyle">@style/mySpinnerDropDownItemStyle</item>
<item name="android:spinnerItemStyle">@style/mySpinnerItemStyle</item>
<item name="android:colorButtonNormal">@color/myDarkBlue</item>
</style>
<style name="actionBarCustomization" parent="@android:style/Widget.Material.Light.ActionBar">
<item name="android:background">@color/white</item>
<item name="android:titleTextStyle">@style/actionBarTextColor</item>
</style>
<style name="actionBarTextColor" parent="@android:style/TextAppearance">
<item name="android:textColor">@color/black</item>
</style>