Jetpack Compose 中的 Unbound Ripple/Indication(相当于 selectableBackgroundBorderless)
Unbound Ripple/Indication in Jetpack Compose (equivalent to selectableBackgroundBorderless)
在 Jetpack Compose 中,clickable
修改器将默认使用 LocalIndication.current
并显示绑定到边框的波纹。这几乎总是看起来很棒,但在某些情况下,圆形的、未绑定的波纹看起来更好。回到视图 Android 中,我们将使用 android:background="?attr/selectableItemBackgroundBorderless
来实现此行为。我们如何在撰写中做到这一点?
示例[source]:
您可以自定义涟漪效果如下:
Modifier.clickable(
interactionSource = remember { MutableInteractionSource() },
indication = rememberRipple(bounded = false), // You can also change the color and radius of the ripple
onClick = {}
)
在 Jetpack Compose 中,clickable
修改器将默认使用 LocalIndication.current
并显示绑定到边框的波纹。这几乎总是看起来很棒,但在某些情况下,圆形的、未绑定的波纹看起来更好。回到视图 Android 中,我们将使用 android:background="?attr/selectableItemBackgroundBorderless
来实现此行为。我们如何在撰写中做到这一点?
示例[source]:
您可以自定义涟漪效果如下:
Modifier.clickable(
interactionSource = remember { MutableInteractionSource() },
indication = rememberRipple(bounded = false), // You can also change the color and radius of the ripple
onClick = {}
)