Ripple-Effekt auf farbigen Hintergrund für Spinner-Dropdown-Elemente (appcompat-v7 V21)
Ich habe versucht, einen Welleneffekt auf die Dropdown-Elemente von Spinner anzuwenden:
activity.java
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
this, R.array.array_name, R.layout.simple_spinner_dropdown_item);
adapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item);
Spinner mSpinner = (Spinner) findViewById(R.id.spinner);
mSpinner.setAdapter(adapter);
simple_spinner_dropdown_item.xml
<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/spinner_ripple"
android:ellipsize="marquee"
android:gravity="center_horizontal"
android:padding="10dip"
android:singleLine="true"
android:textSize="14sp" />
spinner_ripple.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<ripple android:color="?android:attr/colorControlHighlight">
<item><shape>
<solid android:color="@android:color/white" />
</shape>
</item>
</ripple>
</item>
</selector>
aber in der Dropdown-Liste funktioniert es nur für den ersten Artikel undnur wenn das aktuell ausgewählte Element ein anderes als das erste @ i. In allen anderen Fällen wird das Hintergrundelement mit Wellenfarbe gefüllt (da kein Welleneffekt vorliegt). Wo ist mein Code falsch?
Schon versuch: Funktioniert nicht, um eine feste Farbe für den Hintergrund des Dropdown-Elementlayouts festzulegen und den Welleneffekt unter das Spinner-Element zu verschieben.
simple_spinner_dropdown_item.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:ellipsize="marquee"
android:gravity="center_horizontal"
android:padding="10dip"
android:singleLine="true"
android:textSize="14sp" />
activity_layout.xml
<Spinner
android:id="@+id/spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawSelectorOnTop="true"
android:dropDownSelector="@drawable/spinner_ripple" />