问题
Button(backgroundColor = Color.Yellow) {
Row {
Image(asset = image)
Spacer(4.dp)
Text("Button")
}
}
I can not figure out why I can't use background color on Button I followed on Compose Layout codelabs there is a problem in backgroundColor and asset in Image(). Please help me figure out how to use Buton, I'm still new
回答1:
The backgroundColor
for Button
no longer work in 1.0.0-alpha7
Use the below instead
Button(
onClick = {},
colors = ButtonConstants.defaultButtonColors(backgroundColor = Color.Yellow)
) {
/**/
}
回答2:
You can use:
val image = imageResource(R.drawable.xxx)
Button(
onClick = { },
backgroundColor = Color.Yellow) {
Row {
Image(asset = image)
Spacer(Modifier.preferredSize(4.dp))
Text("Button")
}
}
来源:https://stackoverflow.com/questions/64376333/background-color-on-button-in-jetpack-compose