On a Samsung Galaxy Note 10.1 with Android 4.0.4 the GestureDetector does not fire OnGestureListener#onScroll when two fingers are placed on screen (it does for one finger). This works well on other devices. In my application I want to enable scrolling only when at least two fingers are involved.
This is the view implementation to reproduce the phenomena:
public class MyView extends View {
GestureDetector scrollGestureDetector;
public MyView(Context context, AttributeSet attrs) {
super(context, attrs);
scrollGestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onScroll(final MotionEvent e1, final MotionEvent e2, final float distanceX, final float distanceY) {
System.out.println("SCROLL " + distanceX + ", " + distanceY);
return true;
}
});
}
@Override
public boolean onTouchEvent(MotionEvent event) {
scrollGestureDetector.onTouchEvent(event);
return true;
}
}
Is this behavior known/documented/wanted? Are there known workarounds?
You need to implement one more method
onDownin yourGestureDetector.SimpleOnGestureListener, like this:Because according to this document and this guide:
And
You need to
return trueinonDown, so thatonScrollwill be triggered.