Skip to content
Lucas Yuji edited this page Nov 3, 2022 · 1 revision

Zoom

To initialize zoom as a state, just use the code like the example below:

val cameraState = rememberCameraState()
var zoomRatio by remember { mutableStateOf(cameraState.minZoom) }

CameraPreview(
  cameraState = cameraState,
  zoomRatio = zoomRatio 
  onZoomRatioChanged = { zoomRatio = it },
  isPinchToZoomEnabled = true, // default is true
)

addition: isPinchToZoomEnabled just works if you set zoom + onZoomRatioChanged, otherwise doesn't apply the zoom because the CameraPreview is stateless.

CameraState zoom properties

The camera state has some properties it might be useful for you

Clone this wiki locally