更改 Jetpack compose 中 IconButton 的波纹颜色

问题描述 投票:0回答:1

这不是修改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,
        )
    }

波纹颜色不会改变。它保持深灰色。 另外,有没有办法改变波纹的阿尔法??

android android-jetpack-compose ripple iconbutton
1个回答
0
投票

现在您有了 IconButton 的颜色变量:

IconButton(
                    colors = IconButtonDefaults.iconButtonColors(
                        containerColor = colorResource(id = R.color.primary),
                        contentColor = Color.White
                    ),
                    onClick = {
                    // Action
                }) {
                    Icon(Icons.Filled.Edit, contentDescription = null)
                }
© www.soinside.com 2019 - 2024. All rights reserved.