If you just want to get a ripple effect on Android 5.0 devices, the new drawable ripple_bg_drawable :
<?xml version="1.0" encoding="utf-8"?> <ripple xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:color="#d10c1d" <!--ripple color--> tools:targetApi="LOLLIPOP"> <item> <shape android:shape="rectangle"> <solid android:color="#8cc476" /> </shape> </item> </ripple>
then add android:background="@drawable/ripple_bg_drawable" to your widget
or like this:
android:background="?attr/selectableItemBackgroundBorderless"
you must add this code to your layout file !, but this way you cannot adjust the ripple color!
but if you want to be compatible with devices running Android 5.0, the only way is to do it yourself by customizing! Here is the open source RippleView project
source share