我想使用TabRow,但当我点击背景时会产生连锁react ,这是我不想要的.有没有办法改变这一点?我让选项卡的selectedContectColor与页面的背景色相同,但我仍然看到白色涟漪效果.

TabRow(
   modifier = Modifier.height(20.dp),
   selectedTabIndex = selectedIndex,
   indicator = { tabPositions ->
      TabRowDefaults.Indicator(
       modifier = Modifier.customTabIndicatorOffset(
         currentTabPosition = tabPositions[lazyListState.firstVisibleItemIndex]
         tabWidths[lazyListState.firstVisibleItemIndex]
       ),
         color = RED
      )
   },
   backgroundColor = BLACK
) {
    tabList.forEachIndexed{ index, tab ->
     val selected = (selectedIndex == index)
     Tab(
      modifier = Modifier
// Have tried different solutions here where there is a .clickable
// and the indication = null, and set interactionSource = remember{  
//MutableInteractionSource()}
      selected = selected,
      selectedContentColor = BLACK,
      onClick = { 
         animateScrollToItem(selectedIndex)
      },
      text = {
        Text("Text Code")
      }
     )

}

}

您可以在这些文档中看到,selectedContentColor会影响涟漪

Tab Docs

 More docs

More docs

推荐答案

纹波在Tab中定义的selectable修饰符中实现.

你不能禁用它,但你可以改变基于RippleTheme的涟漪的外观.你可以定义一个自定义的RippleTheme,并应用到你的LocalRippleTheme组合.

CompositionLocalProvider(LocalRippleTheme provides NoRippleTheme) {
    //..TabRow()
}

private object NoRippleTheme : RippleTheme {
    @Composable
    override fun defaultColor() = Color.Unspecified

    @Composable
    override fun rippleAlpha(): RippleAlpha = RippleAlpha(0.0f,0.0f,0.0f,0.0f)
}

Android相关问答推荐

如何将子零部件的大小调整为可以调整大小的父组件大小?

懒惰的垂直网格中盒子的重量-Jetpack组合

DocumentFile.canWrite()、DocumentFile.Existes()-使用本地内置手机存储(而不是云)时性能较差(占用太多CPU时间)

如何将.txtassets资源 转换为ArrayList<;字符串>;kotlin格式?

Android Studio SQLite 错误:列不正确(没有这样的列:_id)

错误:无法安装应用程序:INSTALL_PARSE_FAILED_MANIFEST_MALFORMED (React-Native-Android-Studio)

DatePickerDialog (Android/Kotlin) 的两个问题

安卓模拟器打不开

如何在 Jetpack Compose 中设置卡片高度

在 Kotlin 中设置 startActivity() 时类型不匹配

为什么项目捕获对象给我在 Compose 中找不到参考

缺少类 com.google.android.datatransport.runtime.ForcedSender

房间创建三四表关系

Android Compose:LazyColumn 和 Column with verticalScroll 的区别

JetPack Compose - 卡片行中的权重()不起作用

如何在 Android Studio 中创建新的可组合函数?

使用 Room 在 SQLite 中保存复杂的 JSON 响应

如何使用 recyclerview 实现这样的布局?

不能在kotlin的lazycolumn中使用列表

CenterAlignedTopAppBar 滚动行为:未为参数状态传递值