Ahmet K
Ahmet K

Reputation: 813

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).

Upvotes: 4

Views: 7406

Answers (4)

fupduck
fupduck

Reputation: 579

When using Theme.MaterialComponents.* theme the ripple color can be defined by adding following line to i.e. Ouline Button style.

<item name="rippleColor">@color/outline_button_ripple_color</item>

Upvotes: 0

Nouman Ch
Nouman Ch

Reputation: 4121

Simply way to do is define these two colors inside your colors.xml file

<color name="ripple_material_dark">#33ffffff</color>
<color name="ripple_material_light">#1f000000</color>

cheers.

Upvotes: 2

Rohan majhi
Rohan majhi

Reputation: 131

Just add 'item: colorControlHighlight' with the desired color in your styles.xml

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorControlHighlight">@color/white</item>
</style>

Upvotes: 1

user6092941
user6092941

Reputation:

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

Upvotes: 3

Related Questions