首页 > 解决方案 > Jetpack Compose 中的未绑定波纹/指示(相当于 selectableBackgroundBorderless)

问题描述

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

示例[来源]

2

标签: androidandroid-jetpack-compose

解决方案


您可以按如下方式自定义波纹效果:

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

推荐阅读