4

我想自定义 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)
                    }
                }
            )
        }
    )
4

1 回答 1

6

随着1.0.x您可以使用tint参数Icon

actions = {
    IconButton(onClick = { /* doSomething() */ }) {
        Icon(Icons.Filled.Add,
            "contentDescription",
            tint = Color.Red)
    }
}

在此处输入图像描述

于 2020-10-19T09:38:47.150 回答