Change colour of small triangle on spinner in android

Yawar picture Yawar · Sep 18, 2014 · Viewed 51.4k times · Source

enter image description here

How can I change the colour of small triangle at the bottom right corner of spinner like shown in the image? It is showing default grey colour right now. like this

enter image description here

Answer

toni picture toni · Feb 12, 2015

The best and easiest solution:

spinner.getBackground().setColorFilter(getResources().getColor(R.color.red), PorterDuff.Mode.SRC_ATOP);

Other solution (Thanks to Simon) if you don't want change all Spinners:

Drawable spinnerDrawable = spinner.getBackground().getConstantState().newDrawable();

spinnerDrawable.setColorFilter(getResources().getColor(R.color.red), PorterDuff.Mode.SRC_ATOP);

if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
    spinner.setBackground(spinnerDrawable);
}else{
    spinner.setBackgroundDrawable(spinnerDrawable);
}