Is it possible to create Button with gradient background?
@Composable
fun GradientButtonExample() {
val horizontalGradientBrush = Brush.horizontalGradient(
colors = listOf(
Color(0xffF57F17),
Color(0xffFFEE58),
Color(0xffFFF9C4)
)
)
val verticalGradientBrush = Brush.verticalGradient(
colors = listOf(
Color(0xff4E342E),
Color(0xff8D6E63),
Color(0xffD7CCC8)
)
)
Button(onClick = {}) {
Text(
text = "Horizontal Gradient",
modifier = Modifier
.background(brush = horizontalGradientBrush)
)
}
Button(onClick = {}) {
Text(
text = "Vertical Gradient",
modifier = Modifier
.background(brush = verticalGradientBrush)
)
}
}
Adding gradient to Text with background(brush) leaves a margin between Button and Text. When i set background of button with modifier.background(brush = horizontalGradientBrush), Button is drawn with primary color, basically nothing happens. Is it possible to set background of Button, not other components, with gradient colors?

