Handle gestures and touch events for CustomView
summary
A concrete how‑to that builds a working sliding panel with custom shape with canvas and shape morphing tied to drag distance, explains exact touch lifecycle decisions (dispatch, onInterceptTouchEvent and onTouchEvent), shows using view configurations to pick touch slop and fling thresholds, and uses velocityTracker and ViewDragHelper for fling math and smooth animations. The demo updates height and redraws during action_move, cancels child touches when intercepting, and finishes state changes on action_up.
AI-written summary · about
chapters (13)
- 0:00Intro
- 0:19How Android Handles Touch Events?
- 1:51LifeCycle Methods of Touch event
- 4:43Lifecycle of touch events
- 11:24View Configurations
- 12:52Example: Sliding Panel
- 19:41Multi Touch in Touch System
- 21:50Example: Build a drag Multi-touch
- 23:10Velocity Tracker
- 24:57Example: Add fling to drag gesture
- 25:51Default Gestures in Framework
- 28:06Things to take care of
- 32:18ACTION MOVE
related talks
20mAdvanced Android Touches
21mThe Curious Case of Android Gesture Animation
40mPlease, Draw Me a View
39mUnderstand touch event mechanics and master gestures
40mWriting Custom Views for Android
39mAdvanced & Practical MotionLayout
32mA Skeptics Guide to Programmatic Views on Android
40mExploration of Touch & Input in Jetpack Compose
