Jetpack Compose 中的未绑定波纹/指示(相当于 selectableBackgroundBorderless)

Yan*_*ick 4 android android-jetpack-compose

在 Jetpack Compose 中,clickableModifier 将默认使用LocalIndication.current并显示绑定到边框的波纹。这几乎总是看起来很棒,但在某些情况下,圆形、无约束的波纹看起来更好。回到 View Android,我们会用它android:background="?attr/selectableItemBackgroundBorderless来实现这种行为。我们如何在撰写中做到这一点?

示例[来源]

2

Gaë*_*tan 9

您可以按如下方式自定义涟漪效果:

Modifier.clickable(
    interactionSource = remember { MutableInteractionSource() },
    indication = rememberRipple(bounded = false), // You can also change the color and radius of the ripple
    onClick = {}
)
Run Code Online (Sandbox Code Playgroud)