1

I'm trying to change the spinner button color in Android but I can't get it working. Can anyone help?

  <Spinner
       android:id="@+id/spinner1"
       android:layout_width="200dp"
       android:layout_height="35dp"
       android:layout_marginTop="2dp"
       android:background="@null"
       android:layout_weight="1"
       android:layout_marginLeft="11dp"

       android:layout_alignParentBottom="true"
       android:layout_alignParentRight="true"

/>
Pang
  • 9,564
  • 146
  • 81
  • 122
Pushpa Latha
  • 139
  • 1
  • 1
  • 12

4 Answers4

4

you can use this :

Drawable spinnerDrawable = mySpinner.getBackground().getConstantState().newDrawable();
    spinnerDrawable.setColorFilter(getResources().getColor(R.color.blue_m), PorterDuff.Mode.SRC_ATOP);

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

I'm not a android specialist but does this help you?: The Spinner button uses a nine-patch image (http://www.aspose.com/java/imaging-component.aspx). You need to make a nine-patch image in all the different resolutions and then set it as the spinner's background.

See: http://developer.android.com/tools/help/draw9patch.html

0

You can set the spinners background color in xml like this:

android:background="YOUR_HEX_COLOR_CODE"

You can also set a drawable in the background

android:background=@drawable/my_spinner

unrealsoul007
  • 3,809
  • 1
  • 17
  • 33
0

Here are two extra links:

http://android-ui-utils.googlecode.com/hg/asset-studio/dist/nine-patches.html

http://android-holo-colors.com/ (if you want the same shape, just different color (and good for overall themeing)

  • still i did not get answer. spinner does not chaning..still it is in bleck color. what i have to do? – Pushpa Latha Jul 29 '15 at 06:18
  • does this link to another stackoverflow question help you?: –  Jul 29 '15 at 06:23
  • http://stackoverflow.com/questions/11188398/how-to-change-the-spinner-background-design-and-color-for-android –  Jul 29 '15 at 06:23
  • or here a online tutorial: http://androidopentutorials.com/android-how-to-get-holo-spinner-theme-in-android-2-x/ –  Jul 29 '15 at 06:28