如何更改底栏切口的颜色?
我知道它从 MaterialTheme.colors.background
获取颜色,但我不想更改所有组件的背景颜色,仅更改底部栏的背景颜色。 (图中剪出的白色。)
我尝试了不同的方法,例如为底部栏设置一个新主题,但这不起作用。
val bottomBarColors = MaterialTheme.colors.copy(background = Color.LightGray)
...
bottomBar = {
MaterialTheme(
colors = bottomBarColors,
typography = MaterialTheme.typography,
shapes = MaterialTheme.shapes
) {
BottomAppBar(
cutoutShape = fabShape,
content = {
MyBottomNavigation(navController, bottomNavigationItems)
})
}
}
最佳答案
根据您的情况,您可以将 Modifier.background
应用到 BottomAppBar
:
bottomBar = {
BottomAppBar(
modifier = Modifier.background(Color.Red),
cutoutShape = fabShape) {
BottomNavigation {
/* .... */
}
}
}
关于android - Jetpack compose - 更改底部栏切口颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68565454/