Hello everyone. How can I get the real size of an ...
# compose
f
Hello everyone. How can I get the real size of an image when using ContentScale.Fit?? More details in the thread
Copy code
Box(
    modifier = Modifier.fillMaxSize(),
    content = {
        Image(
            imageVector = vectorResource(Res.drawable.ic_car_vertical_stereo),
            contentDescription = null,
            contentScale = ContentScale.Fit,
            modifier = Modifier
                .onSizeChanged { logger.value.d { "width: ${it.width} height: ${it.height}" } }
                .fillMaxSize()
            )
    }
)
The size in onSizeChanged is the measure of the parent because of the fillMaxSize() in the Image composable. But if I do not use it there, the ContentScale.Fit do not work.