https://kotlinlang.org logo
#compose
Title
# compose
v

Vitor Prado

02/25/2021, 9:15 PM
how to draw an image behind view? (I need to draw image as background and the image should be cropped to the content size)
1
c

Chachako

02/26/2021, 8:13 AM
Is this what you want?
Copy code
var srcImage: Bitmap = ...
var croppedImage by remember { mutableStateOf<Bitmap?>(null) }
Widget(
    modifier = Modifier
        .onGloballyPositioned {
            val rect = it.boundsInWindow()
            croppedImage = srcImage.clip(rect)
        }.drawBehind { srcImage?.let(::drawImage) }
)
v

Vitor Prado

02/26/2021, 1:12 PM
I need to use an composable for drawing, my image is a remote image.
a

Adriano Celentano

02/27/2021, 9:29 PM
5 Views