How can I change the background color of a spinner popup?
None of the above solutions worked for me.
The solution was writing in the adapter passed to the spinner a different implementation in the method getDropDownView to display a different layout with custom colors:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View vista = convertView;
// layout for spinner widget
if (vista==null) {
LayoutInflater inflater = actividad.getLayoutInflater();
vista = inflater.inflate(R.layout.fila_colores_spinner, null);
}
return vista;
}
@Override
public View getDropDownView(int position, View convertView,ViewGroup parent) {
View vista = convertView;
//layout for spinner popup
if (vista==null) {
LayoutInflater inflater = actividad.getLayoutInflater();
vista = inflater.inflate(R.layout.fila_colores_spinner_popup, null);
}
return vista;
}
Use android:popupBackground="@drawable/Yourxmlfile.xml" in Your spinner declaration of xml .
For Eg.
<Spinner
android:id="@+id/spinner3"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_weight="50"
android:background="@drawable/gradient_spinner"
android:gravity="center"
android:paddingLeft="40dp"
android:popupBackground="@drawable/radialfront"
>