Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change ?selectableItemBackgroundBorderless ripple color

I'm trying to use ?selectableItemBackgroundBorderless to create borderless ripple for a LinearLayout, it works fine but is not clearly visible.

How can I change the default color for ?selectableItemBackgroundBorderless to make the ripple effect visible?

I've tried applying ThemeOverlay.AppCompat.Dark theme to the parent layout but it doesn't help.

like image 426
Ashish Ranjan Avatar asked Jan 05 '17 23:01

Ashish Ranjan


People also ask

How do I change the color of a selectableItemBackground?

How do I change the color of a selectableItemBackground? Use the foreground attribute as selectableItemBackground and background attribute as the color you want. By doing it like this, you will not have a option to change the ripple effect color.

What is ripple effect in Android?

The touch feedback in Android is a must whenever the user clicks on the item or button ripple effect when clicking on the same, gives confidence to the user that the button has been clicked so that they can wait for the next interaction of the app.

What is selectableItemBackground?

android:selectableItemBackground" is attribute provided by platform which may not support older android versions but only from version they are introduced. android:background="? android:attr/selectableItemBackground" Here use of attr applies to the attribute defined for current theme.


1 Answers

Using the attribute foreground instead of background works well for me:

<Button
...    
android:foreground="?android:attr/selectableItemBackground"
android:backgroundTint="@color/blue"
android:textColor="@color/white"
.../>
like image 131
Matteo Gariglio Avatar answered Sep 18 '22 03:09

Matteo Gariglio