这不是修改Jetpack Compose中IconButton的波纹颜色这个问题以不同的方式转移......
我正在尝试按如下方式更改 IconButton 波纹颜色
IconButton(
modifier = modifier
.indication(
interactionSource = remember { MutableInteractionSource() },
indication = rememberRipple(
bounded = false,
radius = 30.dp,
color = colorResource(id = R.color.error_red)
)
)
.background(colorResource(id = R.color.white), shape = CircleShape),
onClick = { onButtonPressed() }
) {
Icon(
painter = painterResource(R.drawable.ic_busy_small_busy),
contentDescription = buttonContentDesc,
)
}
波纹颜色不会改变。它保持深灰色。 另外,有没有办法改变波纹的阿尔法??
现在您有了 IconButton 的颜色变量:
IconButton(
colors = IconButtonDefaults.iconButtonColors(
containerColor = colorResource(id = R.color.primary),
contentColor = Color.White
),
onClick = {
// Action
}) {
Icon(Icons.Filled.Edit, contentDescription = null)
}