I am trying to zoom images which are items inside my LazyColumn but when i try to zoom in it overlaps content with the other images and the scrolling of lazycolumn also becomes too difficult
var scale by remember { mutableStateOf(1f) }
var offset by remember { mutableStateOf(Offset(0f, 0f)) }
LazyColumn() {
items(mPdfRenderer?.pageCount!!) { message ->
Box(
modifier = Modifier
.fillMaxSize()
.pointerInput(Unit) {
detectTransformGestures { _, pan, zoom, _ ->
scale *= zoom
offset = Offset(
(offset.x + pan.x).coerceIn(
-200.dp.toPx(),
200.dp.toPx()
),
(offset.y + pan.y).coerceIn(
-200.dp.toPx(),
200.dp.toPx()
)
)
}
}
) {
Image(
bitmap = bitmap!!.asImageBitmap(),
contentDescription = "some useful description",
modifier = Modifier
.fillMaxWidth()
.border(width = 1.dp, color = Color.Gray)
.scale(scale)
.offset(offset.x.dp, offset.y.dp)
.aspectRatio(1f)
)
}
}
}
I am actually creating a pdf viewer. How can the zooming be improved so that content is not overlapped and the vertical scrolling remains smooth?
Check this to understand the zooming issue