Search code examples
androidxmllayoutripple

Changing color of Ripple Effect


I got a ListView where the background is black. Now my problem is that the default ripple effect is also black is the user cant really see it.

How can I change the color of the Ripple Effect without be dependent on API level ? (I want to achieve a white color).


Solution

  • You can set this as your views background:

    <ripple xmlns:android="http://schemas.android.com/apk/res/android"
        android:color="?android:attr/colorAccent">
    <item android:id="@android:id/mask">
        <color android:color="#42ffffff" />
    </item>
    

    For more details see this question on stackoverflow:

    What should be the color of the Ripple, colorPrimary or colorAccent? (Material Design)

    And you can use this library for lower apis:

    https://github.com/traex/RippleEffect