0

I am looking for a way to change all the spinners underline color, I made an edited version of this answer:

styles.xml

<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="android:spinnerStyle">@style/MyCustomSpinner</item>
</style>

<style name="MyCustomSpinner" parent="Widget.AppCompat.Spinner.Underlined">
    <item name="android:minHeight">60dp</item>
    <item name="colorControlNormal">@color/colorPrimary</item>
    <item name="android:textColorSecondary">@color/colorPrimary</item>
    <item name="android:colorPrimary">@color/colorPrimary</item>
    <item name="android:strokeColor">@color/colorPrimary</item>
</style>
</resources>

None of these work for me, so I noticed there is this comment on that answer:

This won't work if the Spinner is inside a ScrollView. – IgorGanapolsky

And well... all my spinners are inside ScrollViews, so, how to change all the Spinners Underline color inside ScrollViews?

stramin
  • 2,183
  • 3
  • 29
  • 58

1 Answers1

0

Create new style like this and paste your color inside this style

<style 
name="Spinner" parent="Widget.AppCompat.Light.DropDownItem.Spinner">
<item name="android:paddingStart">0dp</item>
<item name="android:paddingEnd">0dp</item>
<item name="android:backgroundTint">@color/colorWhite</item>
<item name="android:textSize">14sp</item>
</style>

After that set style to spinner like this

<Spinner
  android:layout_width="match_parent"
  android:layout_height="35dp"
  android:id="@+id/spinner"
  android:layout_marginTop="30dp"
  style="@style/Spinner"
/>