Spinner popup background color in Android 5.0

I have a simple counter and I would like to change the background color of the popup. However, when I try to install it using " android: popupBackground " in xml or setPopupBackgroundResource () in the code, I got a strange looking counter, as shown below

spinner_1

If I do not set the background color of the popup or , use the theme of the preliminary material , everything is fine. Does anyone know what is 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> 
+5
source share

Source: https://habr.com/ru/post/1209179/


All Articles