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
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>