1

Please let me know how I can change background colour for a spinner in Android.

<Spinner
        android:id="@+id/addData"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/blue" />

Above code adds the colour BLUE but it also hides the default drop down icon. Is there a way without using custom background xml to add colour and not hide the icon?

Thanks Abhinav Tyagi

Abhinav Tyagi
  • 5,158
  • 3
  • 30
  • 60
  • http://stackoverflow.com/questions/19900017/how-to-customize-the-progress-dialog-in-android ..go through this link for answer – Mr. N.V.Rao Dec 31 '13 at 07:00

2 Answers2

4

There is an easy workaround. Just wrap your Spinner in a FrameLayout (for exapmle) and set background color of your choice to the Layout.

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/white"
    >

    <Spinner
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        />

</FrameLayout>
Will Neithan
  • 1,190
  • 9
  • 12
0

add hexdecimal number for blue android:background="HEX_COLOR_CODE" or use android:popupBackground="YOUR_HEX_COLOR_CODE"

<Spinner
        android:id="@+id/addData"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#0000FF" />
Nambi
  • 11,944
  • 3
  • 37
  • 49