Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing background color of spinner hides dropdown arrow

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.

like image 395
Luke Villanueva Avatar asked Sep 09 '13 08:09

Luke Villanueva


1 Answers

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>
like image 96
Rasel Avatar answered Oct 26 '22 23:10

Rasel