how to draw an image behind view? (I need to draw ...
# compose
v
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
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
I need to use an composable for drawing, my image is a remote image.
a