How can we make a Box zoomable, I did try it image...
# compose
h
How can we make a Box zoomable, I did try it images and it works fine. But i want to make a box zoomable (like it can grow and shrink depending on user gesture)
Copy code
val scale = remember { mutableStateOf(1f) }

Box(modifier = Modifier
    .height(250.dp)
    .fillMaxWidth()
    .background(color = Color.White)
    .graphicsLayer(
        scaleX = maxOf(.5f, minOf(3f, scale.value)),
        scaleY = maxOf(.5f, minOf(3f, scale.value)),
    )
    .pointerInput(Unit) {
        detectTransformGestures { centroid, pan, zoom, rotation ->
            scale.value *= zoom
        }
    }
)
z
I would expect something like this to work. I take it it’s not? Maybe put the gesture modifier before the scale one, I think scales affect pointer inputs so they could be stomping each other.
h
I have found an example in the documentations, I just need to work on giving it limit it to some boundaries https://developer.android.com/jetpack/compose/gestures#multitouch