Interview Prep
Interview questions, roadmaps and practice sets
Tutorials
Free tutorials on 30+ topics
Blog
Career guides, skills and interview tips
Free PDFs
Notes, cheat sheets and question banks
Certificates
Free skill tests and course certificates
Tools & Whiteboard
Free tools you can use right in the browser
Practice Tests
Mock tests, MCQs and quick Q&A
Free LMS
Learn on the Uncodemy LMS
Choose the best training program according to your career.
Improve the performance of your business with our innovative Industrial Training Program.
Read More →
Our instructor-led training classes are designed to make you an expert.
Read More →
Real-life case studies are a great way to demonstrate your practical knowledge.
Read More →
Explore blogs, latest technologies and industry updates with practical examples.
Read More →Browse all available training programs and choose the right one for your career.
Read More →Know more about who we are and what we stand for.
Discover our mission to equip individuals with essential IT skills and industry expertise.
Read More →
Free tutorials, interview questions, tools and calculators to help you learn.
Explore →Learn, practice and plan your career — bilkul free.
Book a free video counselling session and pick the right course for you.
Read More →Every major mobile toolkit has built-in gesture detection, so adding gestures means picking the right API, connecting it to an action, and giving users a visible alternative. This guide shows working code for tap, double-tap, long-press, swipe-to-delete and pinch-to-zoom in Jetpack Compose (Android), SwiftUI (iOS), Flutter and React Native, followed by the design and accessibility rules that stop gestures from becoming hidden traps.

A student builds a notes app for a final-year project. In the demo, the examiner tries to delete a note, cannot find a delete button, and gives up. The developer had added swipe-to-delete, but nothing on screen told anyone it existed. That is the most common gesture problem: the code is easy, the design is the hard part. We will cover both.
| Gesture | Typical meaning | Give users an alternative? |
|---|---|---|
| Tap | Select, open | It is the alternative |
| Double-tap | Like, zoom to fit | Yes, a like or zoom button |
| Long-press | Context menu, start drag | Yes, a "more" (⋮) menu |
| Swipe on a list row | Delete, archive, reply | Yes, an action in the row menu |
| Drag | Reorder, move | Yes, move up/down actions |
| Pinch / spread | Zoom | Yes, zoom buttons or double-tap |
Stick to these meanings. Inventing a new gesture (a three-finger swipe to share, a shake to undo as the only option) means users must be taught it, and most will never find it.
Compose handles gestures through modifiers. Simple taps use clickable; anything richer goes through pointerInput with a detector function.
var liked by remember { mutableStateOf(false) }
var showMenu by remember { mutableStateOf(false) }
Box(
Modifier
.size(200.dp)
.pointerInput(Unit) {
detectTapGestures(
onTap = { /* open the post */ },
onDoubleTap = { liked = !liked },
onLongPress = { showMenu = true }
)
}
)
When you supply onDoubleTap, Compose waits briefly after the first tap to see if a second one follows, so single taps feel slightly slower. Only add double-tap where it earns that delay.
@Composable
fun SwipeCard(onSwipedLeft: () -> Unit) {
var offsetX by remember { mutableFloatStateOf(0f) }
Box(
Modifier
.offset { IntOffset(offsetX.roundToInt(), 0) }
.pointerInput(Unit) {
detectHorizontalDragGestures(
onDragEnd = {
if (offsetX < -300f) onSwipedLeft()
offsetX = 0f
}
) { change, dragAmount ->
change.consume()
offsetX += dragAmount
}
}
.fillMaxWidth()
.height(96.dp)
.background(Color.LightGray)
)
}
The card follows the finger, and if it has moved more than 300 pixels to the left when the finger lifts, the callback fires. For list rows, Material 3 also ships a ready-made SwipeToDismissBox composable, which handles the animation and thresholds for you.
var scale by remember { mutableFloatStateOf(1f) }
val state = rememberTransformableState { zoomChange, _, _ ->
scale = (scale * zoomChange).coerceIn(1f, 5f)
}
Image(
painter = painterResource(R.drawable.photo),
contentDescription = "Product photo",
modifier = Modifier
.graphicsLayer(scaleX = scale, scaleY = scale)
.transformable(state = state)
)
coerceIn(1f, 5f) stops users from shrinking the image to nothing or zooming into a blur. In the older View system the equivalents are GestureDetector and ScaleGestureDetector.
struct PhotoView: View {
@State private var scale: CGFloat = 1.0
@GestureState private var pinch: CGFloat = 1.0
@State private var liked = false
var body: some View {
Image("photo")
.resizable()
.scaledToFit()
.scaleEffect(scale * pinch)
.gesture(
MagnifyGesture()
.updating($pinch) { value, state, _ in
state = value.magnification
}
.onEnded { value in
scale = min(max(scale * value.magnification, 1), 5)
}
)
.onTapGesture(count: 2) { liked.toggle() }
}
}
@GestureState resets to 1.0 automatically when the pinch ends, so the live zoom and the saved zoom stay separate. MagnifyGesture needs iOS 17; on older targets use MagnificationGesture, whose value is the scale itself.
For list rows, do not hand-build swipes. SwiftUI gives you the native behaviour, including the full-swipe shortcut:
List(messages) { message in
Text(message.text)
.swipeActions(edge: .trailing) {
Button(role: .destructive) {
delete(message)
} label: {
Label("Delete", systemImage: "trash")
}
}
}
In UIKit, the same ideas live in UITapGestureRecognizer, UIPanGestureRecognizer and UIPinchGestureRecognizer.
Flutter wraps any widget in GestureDetector and ships higher-level widgets for the common cases.
Dismissible(
key: ValueKey(message.id),
direction: DismissDirection.endToStart,
background: Container(
color: Colors.red,
alignment: Alignment.centerRight,
padding: const EdgeInsets.only(right: 20),
child: const Icon(Icons.delete, color: Colors.white),
),
onDismissed: (_) => setState(() => messages.remove(message)),
child: ListTile(title: Text(message.text)),
)
The key must be unique and stable, such as a database id, or Flutter may remove the wrong row. For zoom, InteractiveViewer(minScale: 1, maxScale: 5, child: Image.asset('assets/photo.jpg')) gives pinch and pan with no extra code, and GestureDetector(onDoubleTap: ..., onLongPress: ...) covers the rest.
The built-in touchables handle taps. For drags and pinches, most projects use react-native-gesture-handler with react-native-reanimated, so gestures run smoothly on the UI thread.
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
import Animated, { useSharedValue, useAnimatedStyle, withSpring } from 'react-native-reanimated';
export function DraggableCard() {
const offset = useSharedValue(0);
const pan = Gesture.Pan()
.onUpdate((e) => { offset.value = e.translationX; })
.onEnd(() => { offset.value = withSpring(0); });
const style = useAnimatedStyle(() => ({
transform: [{ translateX: offset.value }],
}));
return (
<GestureDetector gesture={pan}>
<Animated.View style={[{ height: 96, backgroundColor: '#ddd' }, style]} />
</GestureDetector>
);
}
Wrap your app's root in GestureHandlerRootView, or gestures will not register. Gesture.Pinch() and Gesture.Tap().numberOfTaps(2) follow the same pattern, and Gesture.Simultaneous() lets pinch and pan work together.
WCAG 2.2 success criterion 2.5.1 says that features using multi-point or path-based gestures (pinch, swipe patterns) must also work with a single pointer, and 2.5.7 asks for an alternative to dragging. Screen-reader users also navigate with swipes, so your custom swipe may never reach your code when TalkBack or VoiceOver is on. Expose the same actions as accessibility actions: Modifier.semantics { customActions = ... } in Compose, .accessibilityAction(named:) in SwiftUI, and Semantics in Flutter.
performTouchInput { swipeLeft() }, XCUITest has swipeLeft() and pinch(withScale:velocity:), and Flutter's WidgetTester has drag and fling.If you work in Flutter, these Flutter widget examples show where GestureDetector fits in a widget tree; React Native developers should also read about React Native navigation, because stack navigators add their own swipe-back gesture. Smooth gestures depend on a fast UI thread, so keep mobile app performance in mind, and avoid the mistakes beginners make in Android development. For a final-year project, one well-designed gesture beats five hidden ones. If you want guided practice, Uncodemy's Android app development training covers Compose UI work.