一:针对单个view,去除点击效果,可以在clickable 中添加

1
indication = null, interactionSource = remember { MutableInteractionSource() }

二:针对整个Activity,你可以在最root的compose里设置,通过CompositionLocal(让数据流经界面树的一种隐式方式),属性传递,把children就全部替换了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 @Composable
fun ComposeTheme(
content: @Composable () -> Unit
) {
MaterialTheme(colors = LightColorPalette) {

// 设置全局参数,去除默认点击效果
CompositionLocalProvider(
LocalIndication provides NoIndication
) {
ProvideTextStyle(value = MaterialTheme.typography.body1, content = content)
}
}
}

// null indication
object NoIndication : Indication {
private object NoIndicationInstance : IndicationInstance {
override fun ContentDrawScope.drawIndication() {
drawContent()
}
}

@Composable
override fun rememberUpdatedInstance(interactionSource: InteractionSource): IndicationInstance {
return NoIndicationInstance
}
}