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.
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.
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.
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.
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"
.../>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With