5

I have a simple spinner and I'd like to change the background color of the spinner's popup. However, when I try to set it with either "android:popupBackground" in xml or setPopupBackgroundResource() in the code, I got a weird looking spinner as the picture below

spinner_1

If I don't set the popup background color or use a pre-material design theme, everything is fine. Does anyone know what's wrong?

layout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/holo_blue_dark"
    android:gravity="top|center"
    android:orientation="vertical" >

    <Spinner
        android:id="@+id/spinner_toolbar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        <!-- ======= ERROR HERE =========== -->
        android:popupBackground="#FFFFFF"

        android:spinnerMode="dropdown" />

</LinearLayout>

Activity

public class TestClass extends Activity {

    @Override
    public void onCreate(Bundle b) {
        super.onCreate(b);
        setContentView(R.layout.test_layout);

        // spinner
        Spinner spinner = (Spinner) (findViewById(R.id.spinner_toolbar));

        // create adapter
        if (spinner != null) {

            ArrayAdapter<CharSequence> listAdapter = 
                  ArrayAdapter.createFromResource(this,
                        R.array.app_selection_category,
                        android.R.layout.simple_spinner_item);

            listAdapter.setDropDownViewResource(
                   android.R.layout.simple_spinner_dropdown_item);
            spinner.setAdapter(listAdapter);
        }

    }
}

style

<style name="AppBaseTheme" parent="@android:style/Theme.Material.Light.DarkActionBar">
</style>
Monster Hunter
  • 846
  • 1
  • 12
  • 24
  • 2
    See identical issue: http://stackoverflow.com/questions/26770848/popupbackground-glitches-with-material-design – alanv Dec 16 '14 at 00:34

0 Answers0