Is it possible to draw a gradient over an image drawable using Jetpack Compose?
fun HeroCover() {
Column {
val image = +imageResource(R.drawable.edge_of_tomorrow_poster)
Container(modifier = Height(440.dp) wraps Expanded) {
Clip(shape = RoundedCornerShape(8.dp)) {
DrawImage(image = image)
}
}
}
}
I want to have a translucent gradient drawn on top of the image.
Try this:
Box(
modifier = Modifier
.background(
brush = Brush.verticalGradient(
colors = listOf(
MaterialTheme.colors.primary,
MaterialTheme.colors.primaryVariant
)
)
)
) {
Content()
}