Button(backgroundColor = Color.Yellow) {
Row {
Image(asset = image)
Spacer(4.dp)
Text("Button")
}
}
我不明白为什么我不能在Button
上使用背景色。
我遵循了Compose Layout codelabs。
图像()中的backgroundColor
和asset中存在问题。
发布于 2020-11-22 19:38:07
对alpha11使用1.0.0-alpha09中提供的ButtonDefaults
Button(
onClick = {},
colors = ButtonDefaults.buttonColors(backgroundColor = Color.Yellow)
) {
/**/
}
旧版本
Button
的backgroundColor
在1.0.0-alpha7
中不再有效
请使用下面的内容
Button(
onClick = {},
colors = ButtonConstants.defaultButtonColors(backgroundColor = Color.Yellow)
) {
/**/
}
发布于 2020-10-16 01:01:11
通过1.0.x
,您可以使用
Button(
onClick = { },
colors = ButtonDefaults.buttonColors(
backgroundColor = Color.White,
contentColor = Color.Red)
)
发布于 2020-12-19 07:28:25
在1.0.0-alpha09
使用时,不推荐使用ButtonConstants.defaultButtonColor
:
colors = ButtonDefaults.buttonColors(backgroundColor = Color.Yellow)
https://stackoverflow.com/questions/64376333
复制相似问题