টেনে আনুন, সোয়াইপ করুন এবং ফ্লিং করুন৷
সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
draggable
মডিফায়ার হল উচ্চ-স্তরের এন্ট্রি পয়েন্ট যা ইঙ্গিতগুলিকে একটি একক অভিযোজনে টেনে আনতে এবং পিক্সেলে ড্র্যাগ দূরত্ব রিপোর্ট করে।
এটা মনে রাখা গুরুত্বপূর্ণ যে এই মডিফায়ারটি scrollable
এর মতো, এতে এটি শুধুমাত্র অঙ্গভঙ্গি সনাক্ত করে। আপনাকে স্টেট ধরে রাখতে হবে এবং এটিকে স্ক্রিনে উপস্থাপন করতে হবে, উদাহরণস্বরূপ, offset
মডিফায়ারের মাধ্যমে উপাদানটিকে সরানো:
@Composable
private fun DraggableText() {
var offsetX by remember { mutableStateOf(0f) }
Text(
modifier = Modifier
.offset { IntOffset(offsetX.roundToInt(), 0) }
.draggable(
orientation = Orientation.Horizontal,
state = rememberDraggableState { delta ->
offsetX += delta
}
),
text = "Drag me!"
)
}
আপনি যদি পুরো টেনে নেওয়ার অঙ্গভঙ্গি নিয়ন্ত্রণ করতে চান, তাহলে pointerInput
মডিফায়ারের মাধ্যমে পরিবর্তে টেনে আনা অঙ্গভঙ্গি আবিষ্কারক ব্যবহার করার কথা বিবেচনা করুন।
@Composable
private fun DraggableTextLowLevel() {
Box(modifier = Modifier.fillMaxSize()) {
var offsetX by remember { mutableStateOf(0f) }
var offsetY by remember { mutableStateOf(0f) }
Box(
Modifier
.offset { IntOffset(offsetX.roundToInt(), offsetY.roundToInt()) }
.background(Color.Blue)
.size(50.dp)
.pointerInput(Unit) {
detectDragGestures { change, dragAmount ->
change.consume()
offsetX += dragAmount.x
offsetY += dragAmount.y
}
}
)
}
}

সোয়াইপ
swipeable
সংশোধক আপনাকে এমন উপাদানগুলিকে টেনে আনতে দেয় যা মুক্তি পেলে, একটি অভিযোজনে সংজ্ঞায়িত দুটি বা তার বেশি অ্যাঙ্কর পয়েন্টের দিকে অ্যানিমেট করে। এটির জন্য একটি সাধারণ ব্যবহার হল একটি 'সোয়াইপ-টু-খারিজ' প্যাটার্ন বাস্তবায়ন করা।
এটা মনে রাখা গুরুত্বপূর্ণ যে এই সংশোধক উপাদানটিকে সরায় না, এটি শুধুমাত্র অঙ্গভঙ্গি সনাক্ত করে। আপনাকে স্টেট ধরে রাখতে হবে এবং এটিকে স্ক্রিনে উপস্থাপন করতে হবে, উদাহরণস্বরূপ, offset
মডিফায়ারের মাধ্যমে উপাদানটিকে সরানোর মাধ্যমে।
swipeable
মডিফায়ারে সোয়াইপযোগ্য অবস্থার প্রয়োজন, এবং স্মরণ করা যায় এবং স্মরণে রাখা rememberSwipeableState()
এই অবস্থাটি অ্যাঙ্করগুলিতে প্রোগ্রাম্যাটিকভাবে অ্যানিমেট করার জন্য দরকারী পদ্ধতিগুলির একটি সেটও সরবরাহ করে (দেখুন snapTo
, animateTo
, performFling
, এবং performDrag
) পাশাপাশি টেনে আনার অগ্রগতি পর্যবেক্ষণ করার বৈশিষ্ট্যগুলিও।
সোয়াইপ অঙ্গভঙ্গি বিভিন্ন থ্রেশহোল্ড প্রকারের জন্য কনফিগার করা যেতে পারে, যেমন FixedThreshold(Dp)
এবং FractionalThreshold(Float)
, এবং সেগুলি প্রতিটি অ্যাঙ্কর পয়েন্ট থেকে টু কম্বিনেশনের জন্য আলাদা হতে পারে।
আরও নমনীয়তার জন্য, আপনি সীমা অতিক্রম করার সময় resistance
কনফিগার করতে পারেন এবং এছাড়াও, velocityThreshold
যা পরবর্তী অবস্থায় একটি সোয়াইপ অ্যানিমেট করবে, এমনকি যদি অবস্থানগত thresholds
পৌঁছানো নাও হয়।
@OptIn(ExperimentalMaterialApi::class)
@Composable
private fun SwipeableSample() {
val width = 96.dp
val squareSize = 48.dp
val swipeableState = rememberSwipeableState(0)
val sizePx = with(LocalDensity.current) { squareSize.toPx() }
val anchors = mapOf(0f to 0, sizePx to 1) // Maps anchor points (in px) to states
Box(
modifier = Modifier
.width(width)
.swipeable(
state = swipeableState,
anchors = anchors,
thresholds = { _, _ -> FractionalThreshold(0.3f) },
orientation = Orientation.Horizontal
)
.background(Color.LightGray)
) {
Box(
Modifier
.offset { IntOffset(swipeableState.offset.value.roundToInt(), 0) }
.size(squareSize)
.background(Color.DarkGray)
)
}
}

{% শব্দার্থে %}
{% endverbatim %} আপনার জন্য প্রস্তাবিত
{% শব্দার্থে %} {% endverbatim %}
এই পৃষ্ঠার কন্টেন্ট ও কোডের নমুনাগুলি Content License-এ বর্ণিত লাইসেন্সের অধীনস্থ। 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,["# Drag, swipe, and fling\n\nThe\n[`draggable`](/reference/kotlin/androidx/compose/foundation/gestures/package-summary#(androidx.compose.ui.Modifier).draggable(androidx.compose.foundation.gestures.DraggableState,androidx.compose.foundation.gestures.Orientation,kotlin.Boolean,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Boolean,kotlin.coroutines.SuspendFunction2,kotlin.coroutines.SuspendFunction2,kotlin.Boolean))\nmodifier is the high-level entry point to drag gestures in a single orientation,\nand reports the drag distance in pixels.\n\nIt's important to note that this modifier is similar to `scrollable`, in that it\nonly detects the gesture. You need to hold the state and represent it on screen\nby, for example, moving the element via the\n[`offset`](/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.ui.Modifier).offset(androidx.compose.ui.unit.Dp,%20androidx.compose.ui.unit.Dp))\nmodifier:\n\n\n```kotlin\n@Composable\nprivate fun DraggableText() {\n var offsetX by remember { mutableStateOf(0f) }\n Text(\n modifier = Modifier\n .offset { IntOffset(offsetX.roundToInt(), 0) }\n .draggable(\n orientation = Orientation.Horizontal,\n state = rememberDraggableState { delta -\u003e\n offsetX += delta\n }\n ),\n text = \"Drag me!\"\n )\n}https://github.com/android/snippets/blob/dd30aee903e8c247786c064faab1a9ca8d10b46e/compose/snippets/src/main/java/com/example/compose/snippets/touchinput/gestures/GesturesSnippets.kt#L250-L264\n```\n\n\u003cbr /\u003e\n\nIf you need to control the whole dragging gesture, consider using the drag\ngesture detector instead, via the\n[`pointerInput`](/reference/kotlin/androidx/compose/ui/input/pointer/package-summary#(androidx.compose.ui.Modifier).pointerInput(kotlin.Any,kotlin.coroutines.SuspendFunction1))\nmodifier.\n\n\n```kotlin\n@Composable\nprivate fun DraggableTextLowLevel() {\n Box(modifier = Modifier.fillMaxSize()) {\n var offsetX by remember { mutableStateOf(0f) }\n var offsetY by remember { mutableStateOf(0f) }\n\n Box(\n Modifier\n .offset { IntOffset(offsetX.roundToInt(), offsetY.roundToInt()) }\n .background(Color.Blue)\n .size(50.dp)\n .pointerInput(Unit) {\n detectDragGestures { change, dragAmount -\u003e\n change.consume()\n offsetX += dragAmount.x\n offsetY += dragAmount.y\n }\n }\n )\n }\n}https://github.com/android/snippets/blob/dd30aee903e8c247786c064faab1a9ca8d10b46e/compose/snippets/src/main/java/com/example/compose/snippets/touchinput/gestures/GesturesSnippets.kt#L268-L288\n```\n\n\u003cbr /\u003e\n\nSwiping\n-------\n\nThe\n[`swipeable`](/reference/kotlin/androidx/compose/material/package-summary#(androidx.compose.ui.Modifier).swipeable(androidx.compose.material.SwipeableState,kotlin.collections.Map,androidx.compose.foundation.gestures.Orientation,kotlin.Boolean,kotlin.Boolean,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Function2,androidx.compose.material.ResistanceConfig,androidx.compose.ui.unit.Dp))\nmodifier lets you drag elements which, when released, animate towards typically\ntwo or more anchor points defined in an orientation. A common usage for this is\nto implement a 'swipe-to-dismiss' pattern.\n| **Caution:** The [`swipeable`](/reference/kotlin/androidx/compose/material/package-summary#(androidx.compose.ui.Modifier).swipeable(androidx.compose.material.SwipeableState,kotlin.collections.Map,androidx.compose.foundation.gestures.Orientation,kotlin.Boolean,kotlin.Boolean,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Function2,androidx.compose.material.ResistanceConfig,androidx.compose.ui.unit.Dp)) APIs have been replaced by Foundation's [`anchoredDraggable`](/reference/kotlin/androidx/compose/foundation/gestures/package-summary#(androidx.compose.ui.Modifier).anchoredDraggable(androidx.compose.foundation.gestures.AnchoredDraggableState,androidx.compose.foundation.gestures.Orientation,kotlin.Boolean,kotlin.Boolean,androidx.compose.foundation.interaction.MutableInteractionSource)) APIs in Jetpack Compose 1.6.0-alpha01.\n\nIt's important to note that this modifier does not move the element, it only\ndetects the gesture. You need to hold the state and represent it on screen by,\nfor example, moving the element via the\n[`offset`](/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.ui.Modifier).offset(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp))\nmodifier.\n\nThe swipeable state is required in the `swipeable` modifier, and can be created\nand remembered with\n[`rememberSwipeableState()`](/reference/kotlin/androidx/compose/material/package-summary#rememberSwipeableState(kotlin.Any,androidx.compose.animation.core.AnimationSpec,kotlin.Function1)).\nThis state also provides a set of useful methods to programmatically animate to\nanchors (see\n[`snapTo`](/reference/kotlin/androidx/compose/material/SwipeableState#snapTo(kotlin.Any)),\n[`animateTo`](/reference/kotlin/androidx/compose/material/SwipeableState#animateTo(kotlin.Any,androidx.compose.animation.core.AnimationSpec)),\n[`performFling`](/reference/kotlin/androidx/compose/material/SwipeableState#performFling(kotlin.Float)),\nand\n[`performDrag`](/reference/kotlin/androidx/compose/material/SwipeableState#performDrag(kotlin.Float)))\nas well as properties to observe the dragging progress.\n\nThe swipe gesture can be configured to have different threshold types, such as\n[`FixedThreshold(Dp)`](/reference/kotlin/androidx/compose/material/FixedThreshold#FixedThreshold(androidx.compose.ui.unit.Dp))\nand\n[`FractionalThreshold(Float)`](/reference/kotlin/androidx/compose/material/FractionalThreshold#FractionalThreshold(kotlin.Float)),\nand they can be different for each anchor point from-to combination.\n\nFor more flexibility, you can configure the `resistance` when swiping past the\nbounds and, also, the `velocityThreshold` which will animate a swipe to the\nnext state, even if the positional `thresholds`have not been reached.\n\n\n```kotlin\n@OptIn(ExperimentalMaterialApi::class)\n@Composable\nprivate fun SwipeableSample() {\n val width = 96.dp\n val squareSize = 48.dp\n\n val swipeableState = rememberSwipeableState(0)\n val sizePx = with(LocalDensity.current) { squareSize.toPx() }\n val anchors = mapOf(0f to 0, sizePx to 1) // Maps anchor points (in px) to states\n\n Box(\n modifier = Modifier\n .width(width)\n .swipeable(\n state = swipeableState,\n anchors = anchors,\n thresholds = { _, _ -\u003e FractionalThreshold(0.3f) },\n orientation = Orientation.Horizontal\n )\n .background(Color.LightGray)\n ) {\n Box(\n Modifier\n .offset { IntOffset(swipeableState.offset.value.roundToInt(), 0) }\n .size(squareSize)\n .background(Color.DarkGray)\n )\n }\n}https://github.com/android/snippets/blob/dd30aee903e8c247786c064faab1a9ca8d10b46e/compose/snippets/src/main/java/com/example/compose/snippets/touchinput/gestures/GesturesSnippets.kt#L292-L320\n```\n\n\u003cbr /\u003e\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)\n- [Advanced animation example: Gestures {:#gesture-and-animation}](/develop/ui/compose/animation/advanced)\n- [Value-based animations](/develop/ui/compose/animation/value-based)"]]