Categories
discuss

Unbound Ripple/Indication in Jetpack Compose (equivalent to selectableBackgroundBorderless)

In Jetpack Compose the clickable Modifier will by default use LocalIndication.current and show a ripple that is bound to the border. That looks great almost always, but there are some circumstances where a rounded, unbound ripple looks better. Back in View Android we would’ve used android:background="?attr/selectableItemBackgroundBorderless to achieve this behaviour. How can we do it in compose?

Example [source]:

2

Answer

You can customise the ripple effect as follow:

Modifier.clickable(
    interactionSource = remember { MutableInteractionSource() },
    indication = rememberRipple(bounded = false), // You can also change the color and radius of the ripple
    onClick = {}
)
Source: stackoverflow
Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Privacy Policy, and Copyright Policy. Content is available under CC BY-SA 3.0 unless otherwise noted. The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 © No Copyrights, All Questions are retrived from public domain..