멀티터치: 화면 이동, 확대/축소, 회전
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
화면 이동, 확대/축소, 회전에 사용되는 멀티터치 동작을 감지하려면 transformable
수정자를 사용하세요. 이 수정자는 자체적으로 요소를 변환하지 않으며 동작만 감지합니다.
@Composable
private fun TransformableSample() {
// set up all transformation states
var scale by remember { mutableStateOf(1f) }
var rotation by remember { mutableStateOf(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()
)
}
확대/축소, 화면 이동, 회전을 다른 동작과 결합해야 하는 경우 PointerInputScope.detectTransformGestures
감지기를 사용할 수 있습니다.
추천 서비스
- 참고: JavaScript가 사용 중지되어 있으면 링크 텍스트가 표시됩니다.
- 동작 이해하기
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-08-23(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-08-23(UTC)"],[],[],null,["# Multitouch: Panning, zooming, rotating\n\nTo detect multitouch gestures used for panning, zooming and rotating, you can\nuse the `transformable` modifier. This modifier does not transform elements by\nitself, it only detects the gestures.\n\n\n```kotlin\n@Composable\nprivate fun TransformableSample() {\n // set up all transformation states\n var scale by remember { mutableStateOf(1f) }\n var rotation by remember { mutableStateOf(0f) }\n var offset by remember { mutableStateOf(Offset.Zero) }\n val state = rememberTransformableState { zoomChange, offsetChange, rotationChange -\u003e\n scale *= zoomChange\n rotation += rotationChange\n offset += offsetChange\n }\n Box(\n Modifier\n // apply other transformations like rotation and zoom\n // on the pizza slice emoji\n .graphicsLayer(\n scaleX = scale,\n scaleY = scale,\n rotationZ = rotation,\n translationX = offset.x,\n translationY = offset.y\n )\n // add transformable to listen to multitouch transformation events\n // after offset\n .transformable(state = state)\n .background(Color.Blue)\n .fillMaxSize()\n )\n}https://github.com/android/snippets/blob/dd30aee903e8c247786c064faab1a9ca8d10b46e/compose/snippets/src/main/java/com/example/compose/snippets/touchinput/gestures/GesturesSnippets.kt#L324-L352\n```\n\n\u003cbr /\u003e\n\nIf you need to combine zooming, panning and rotation with other gestures, you\ncan use the\n[`PointerInputScope.detectTransformGestures`](/reference/kotlin/androidx/compose/foundation/gestures/package-summary#(androidx.compose.ui.input.pointer.PointerInputScope).detectTransformGestures(kotlin.Boolean,kotlin.Function4))\ndetector.\n\nRecommended for you\n-------------------\n\n- Note: link text is displayed when JavaScript is off\n- [Understand gestures](/develop/ui/compose/touch-input/pointer-input/understand-gestures)"]]