Draws [shape] with a solid [color] behind the content.
DrawBackgroundColor
@Composable
fun DrawBackgroundColor() {
Text("Text with background", Modifier.background(color = Color.Magenta).padding(10.dp))
}
DrawBackgroundShapedBrush
@Composable
fun DrawBackgroundShapedBrush() {
val gradientBrush =
Brush.horizontalGradient(
colors = listOf(Color.Red, Color.Blue, Color.Green),
startX = 0.0f,
endX = 500.0f,
)
Text(
"Text with gradient back",
Modifier.background(brush = gradientBrush, shape = CutCornerShape(8.dp)).padding(10.dp),
)
}