【问题标题】:Unbound Ripple/Indication in Jetpack Compose (equivalent to selectableBackgroundBorderless)Jetpack Compose 中的未绑定波纹/指示(相当于 selectableBackgroundBorderless)
【发布时间】:2021-02-26 13:52:47
【问题描述】:

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

例如[source]:

【问题讨论】:

    标签: android android-jetpack-compose


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2021-06-23
      • 2022-12-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-28
      • 1970-01-01
      • 2021-08-04
      • 1970-01-01
      相关资源
      最近更新 更多