Per rilevare i gesti multitocco utilizzati per la panoramica, lo zoom e la rotazione, puoi utilizzare il modificatore transformable. Questo modificatore non trasforma gli elementi da solo, ma rileva solo i gesti.
@Composable private fun TransformableSample() { // set up all transformation states var scale by remember { mutableFloatStateOf(1f) } var rotation by remember { mutableFloatStateOf(0f) } var offset by remember { mutableStateOf(Offset.Zero) } val state = rememberTransformableState { zoomChange, offsetChange, rotationChange -> scale *= zoomChange rotation += rotationChange offset += offsetChange } Box( Modifier // apply other transformations like rotation and zoom // on the pizza slice emoji .graphicsLayer( scaleX = scale, scaleY = scale, rotationZ = rotation, translationX = offset.x, translationY = offset.y ) // add transformable to listen to multitouch transformation events // after offset .transformable(state = state) .background(Color.Blue) .fillMaxSize() ) }
Se devi combinare lo zoom, la panoramica e la rotazione con altri gesti, puoi utilizzare il rilevatore PointerInputScope.detectTransformGestures.
Consigliati per te
- Nota: il testo del link viene visualizzato quando JavaScript è disattivato
- Informazioni sui gesti