I am trying to find resources explaining how I can change the style of a button in a Material Design theme.
Coloring widgets are pretty simple now with the new appcompat-v7: 21.
As long as you use appcompat-v7: 21, you can replace all old Switch widgets with SwitchCompat widgets. So in your xml layouts, instead of the old Switch tag, use android.support.v7.widget.SwitchCompat .
Then, in your styles.xml file, make sure the parent theme of your application is Theme.AppCompat theme, for example Theme.AppCompat.Light .
Finally, the key should indicate your own value for colorAccent :
<item name="colorAccent">@color/my_fancy_color</item>
The color that you specify for colorAccent will be used to color widgets in your application, such as SwitchCompats , EditTexts , RadioButtons , etc.
So your .xml style might look something like this:
<style name="Theme.MyTheme" parent="Theme.AppCompat.Light"> <item name="colorPrimary">@color/color_primary</item> <item name="colorPrimaryDark">@color/color_primary_dark</item> <item name="colorAccent">@color/my_fancy_color</item> </style>
Where are the drawings that I can use to create my own version?
I would not recommend changing the drawings directly, but they are located in
sdk/platforms/android-21/data/res/drawable-XXXX
and the files are called
btn_switch_to_off_mtrl_XXXXX.9.png
btn_switch_to_on_mtrl_XXXXX.9.png
switch_track_mtrl_alpha.9.png