There is a library on Github, i.e. Layout material Ripple Layout . This library supports devices up to Lollipop and Lollipop. In addition, you can create your own ripple color. Here's the use:
Spinner spinner = (Spinner) findViewById(R.id.spinner); MaterialRippleLayout.on(spinner) .rippleColor(Color.BLACK) .create();
But I do not use this library. I use the default empty Spinner line, which is presented in the rev 23.0.1 support library, by compiling: compile 'com.android.support:appcompat-v7:23.0.1' in the build.gradle the app module.
So here is my complete code for the Spinner layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <Spinner android:id="@+id/spinner" android:layout_width="wrap_content" android:layout_height="wrap_content" android:dropDownVerticalOffset="@dimen/dropDown_spinner" style="@style/SpinnerStyle"/> </RelativeLayout>
The style is defined in res/values/styles.xml :
<style name="SpinnerStyle" parent="Widget.AppCompat.Light.Spinner.DropDown.ActionBar"> <item name="android:background">?android:selectableItemBackground</item> <item name="android:dropDownSelector">?android:selectableItemBackground</item> <item name="android:divider">@null</item> <item name="overlapAnchor">true</item> </style>
After that, the ripple effect should work as expected.
source share