As I wrote in my question, I want to change the color of the drop down arrow (the default arrow, not a custom arrow or something like that) of a Spinner
in XML, but the problem is that I couldn't find anything to make reference to it from the XML
.
Is it possible? If yes, how can I change the color?
Thanks in advance.
Only works above API Level 21
There are three ways to achieve that.
1. Through code:
In your xml, make sure your spinner has an id. Let's say we have a spinner with id "spinner".
In your code, add the following in your onCreate():
where red is your defined color in colors.xml in the values folder.
2. Through xml:
For API 21+:
or if you use the support library, you can use:
3. Through drawables:
You can use this online tool: http://android-holo-colors.com
This will generate custom drawables for any view you want with your preferred color. Make sure you select spinner, then download the resources.
try this:
use backgroundTint attribute
if min_SDK < 21(Lollipop) you should use AppCompatSpinner
Use this dependency for create a very nice and easy spinner and use "app:arrowTint="@color/green" to change the arrow color
If (API 21+) {
you can use directly
android:backgroundTint="@color/color"
, inside your Spinner:} else {
create your own style:
then into Spinner:
}
Note: you can use the style method in all API's.