我想自定义 IconButton 的颜色,而不是使用 TopAppBar 上设置的默认值,而是使用 android.compose.material没有插槽 api 可以更改它。
Scaffold(
topBar = {
TopAppBar(
title = {
Text(text = "LayoutsCodelab")
},
actions = {
IconButton(onClick = { /* doSomething() */ }) { // <- why it has the theme color and how to custom it.
Icon(Icons.Filled.Favorite)
}
}
)
}
)
最佳答案
您可以使用 tint
Icon
中的参数可组合:
actions = {
IconButton(onClick = { /* doSomething() */ }) {
Icon(Icons.Filled.Add,
"contentDescription",
tint = Color.Red)
}
}
关于android - 如何自定义 IconButton 的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64424206/