Android: can you have a ripple effect whose default state color is transparent?

ZakTaccardi picture ZakTaccardi · Feb 3, 2015 · Viewed 9.5k times · Source

Something like the following, but it doesn't work. If I switch the drawable color to something like blue, it works.

<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    android:color="?android:colorControlHighlight">
    <item android:drawable="@android:color/transparent"/>
</ripple>

Answer

JMPergar picture JMPergar · Apr 21, 2015

It's necessary to add a mask:

<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    android:color="?android:colorControlHighlight">
     <item android:id="@android:id/mask">
       <color android:color="@android:color/white" />
     </item>
</ripple>