Michael
Michael

Reputation: 9904

How to change color or drawable of Spinner arrow

Just want to change the color of the Spinner arrow (@color or @drawable)

enter image description here

This is the only code that did something and it make the drawable the entire background of the spinner. (I've tried many other ideas with no luck)

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

<style name="SpinnerColor" parent="Base.Widget.AppCompat.Spinner">
    <item name="android:background">@drawable/ic_add_white_24dp</item>
</style>

Here is how I am inflating my Spinner

mNavigationSpinner = new Spinner(getSupportActionBar().getThemedContext());
mNavigationSpinner.setAdapter(spinnerAdapter);

mNavigationSpinner.setOnItemSelectedListener(this);
toolbar.addView(mNavigationSpinner);

Upvotes: 3

Views: 9400

Answers (3)

Rk215 Tech
Rk215 Tech

Reputation: 542

okay. you can change the dropdown arrow color using below code

in your styles.xml file just add this attribute and you good to go.

 <item name="android:colorControlNormal">@color/colorAccent</item>

for example.

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
       <item name="android:colorControlNormal">@color/colorAccent</item>
    </style>

Upvotes: 1

Michael
Michael

Reputation: 9904

This is my fix.

It was a style call in the Toolbar that I had forgotten about.

In toolbar.xml

This

app:theme="@style/ThemeOverlay.AppCompat.Light"

Change to this

app:theme="@style/ThemeOverlay.AppCompat"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"

Looks identical to this

Upvotes: 2

logcat
logcat

Reputation: 1

Try changing

<item name="android:spinnerStyle">@style/SpinnerColor</item>

to

<item name="android:actionDropDownStyle">@style/SpinnerColor</item>

where the

<item name="android:background">@drawable/ic_add_white_24dp</item>

in SpinnerColor style is a StateListDrawable. Items of the StateListDrawable are 9-patch drawables.

Upvotes: 0

Related Questions