just wondering... is there maybe a way, to add a g...
# compose
p
just wondering... is there maybe a way, to add a gradient overlay to
Image
without using another
Box
like following example. Is there something like
Modifier.foreground
, dunno.
Copy code
Box {
    Image(
        painter = painterResource(id = R.drawable.bg_home),
        contentDescription = null,
        modifier = Modifier.fillMaxSize(),
    )

    Box(
        Modifier
            .matchParentSize()
            .background(
                Brush.verticalGradient(
                    colors = listOf(
                        Color.Black.copy(alpha = 0f),
                        Color.Black.copy(alpha = 0.8f),
                    ),
                ),
            )
    )
}
r
You can use a drawWithContent() modifier. See example here: https://developer.android.com/jetpack/compose/graphics/draw/modifiers#drawwithcontent
🔥 1
p
will try that out, thanks!