Scrolling Logs Using GestureDetector onScroll

I use GestureDetector to implement scrolling inside a custom View . My implementation is based on the following: Smooth scrolling with inertia and edge resistance / snapback

I noticed a short pause before scrolling started: I looked at onScroll messages and noticed that the first one comes only after a larger finger movement, which causes a noticeable lag at the beginning of scrolling. After that, the scrolling is smooth.

It seems that the GestureDetector starts sending onScroll messages only after a minimum distance between moving events, to make sure that the gesture is not long or short-lived (btw I set setIsLongpressEnabled(false) ).

Is there a way to change this behavior and create a smooth scroll without implementing custom scroll gestures using low-touch events?

+8
android scroll touch
source share
1 answer

Answer: no, you need to create your own GestureDetector . If you look at the Android source code ( GestureDetector.java ), lines 524 through 540 are used to detect the β€œtouch slop” for a single tap. In particular, line 528 prevents the onScroll event from onScroll raised until the movement is outside the bounds of the sensor blade (which is pulled out of the view configuration). You cannot change the view configuration, and slop is hardcoded at 16 pixels. This is the radius that causes the delay you see.

+10
source share

All Articles