6

I have a spinnder and set its background color to white. The problem is, the arrow's gone. I don't know why. Is there something wrong?

I'm using this code.

drivers = (Spinner) findViewById(R.id.spinner1);
drivers.setBackgroundColor(Color.WHITE);

ArrayAdapter<String> adp1=new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item , driverList);
adp1.setDropDownViewResource(android.R.layout.select_dialog_singlechoice);
drivers.setAdapter(adp1);
drivers.setPrompt("Select Driver");

Here's my layout:

<Spinner
    android:id="@+id/spinner1"
    android:layout_width="330dp"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_marginTop="10dp"
    android:ellipsize="marquee"/>

Any ideas? I want to retain the white background but the dropdown arrow should show.

Luke Villanueva
  • 2,030
  • 8
  • 44
  • 94

2 Answers2

13

I solved this problem wrapping spinner by RelativeLayOut and using background for RelativeLayOut.Then arrow does not disappears.

<RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#f00" >
            <Spinner
        android:id="@+id/spinner1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    </RelativeLayout>
Rasel
  • 5,488
  • 3
  • 30
  • 39
2

Set background image (with arrow) instead of color.

Code

drivers.setBackgroundResource(R.drawable.spinner_img);
Ullas
  • 11,450
  • 4
  • 33
  • 50
Brijesh Patel
  • 676
  • 1
  • 5
  • 13