मल्टीटच: पैन करना, ज़ूम करना, और घुमाना
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
पैन करने, ज़ूम करने, और घुमाने के लिए इस्तेमाल होने वाले मल्टीटच जेस्चर का पता लगाने के लिए,
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
डिटेक्टर.
आपके लिए सुझाव
इस पेज पर मौजूद कॉन्टेंट और कोड सैंपल कॉन्टेंट के लाइसेंस में बताए गए लाइसेंस के हिसाब से हैं. Java और OpenJDK, Oracle और/या इससे जुड़ी हुई कंपनियों के ट्रेडमार्क या रजिस्टर किए हुए ट्रेडमार्क हैं.
आखिरी बार 2025-08-27 (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-27 (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)"]]