Skip to content

Instantly share code, notes, and snippets.

@randallmitchell
Created October 3, 2018 04:29
Show Gist options
  • Save randallmitchell/542cc6ae8cbb1fea5c63d2ffc57abd68 to your computer and use it in GitHub Desktop.
Save randallmitchell/542cc6ae8cbb1fea5c63d2ffc57abd68 to your computer and use it in GitHub Desktop.
Setting the theme for spinners when using an AppCompat theme.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="@style/Theme.AppCompat.Light.NoActionBar">
<item name="spinnerStyle">@style/Spinner</item>
<item name="android:spinnerItemStyle">@style/Spinner.Item</item>
<item name="spinnerDropDownItemStyle">@style/Spinner.Dropdown</item>
</style>
<!-- styling for the main widget -->
<style name="Spinner" parent="@style/Widget.AppCompat.Spinner">
<item name="android:background">@drawable/spinner_background</item>
</style>
<!-- styling for the text inside the main widget (includes padding, font, etc.) -->
<style name="Spinner.Item" parent="@style/Widget.AppCompat.TextView.SpinnerItem">
<item name="android:textColor">@color/text_color</item>
<item name="android:textSize">16sp</item>
<item name="android:fontFamily">@font/main_data_entry_font</item>
</style>
<!-- styling for drop down items -->
<style name="Spinner.Dropdown" parent="@style/Widget.AppCompat.Spinner.DropDown">
<item name="android:textColor">@color/text_color</item>
<item name="android:textSize">16sp</item>
<item name="android:fontFamily">@font/main_data_entry_font</item>
</style>
</resources>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment