Home > Tricks & Tips > Improve finger/multi-touch on ViewGroup

Improve finger/multi-touch on ViewGroup

I’ve been working on an application that users can take many touch operations on screen (ViewGroup) like: Click, LongClick, Swipe-Up, Swipe-Down, Fling-Left, Fling-Right, Pinch-In, Pinch-Out, DoubleTap…

However, my application has a problem, that is, the Pinch-In and Fling-Left/-Right process at the same time.

The process is like:


-> (1) GestureListener : TRUE -> fire onFling() , FALSE -> go to (2)

-> (2) ACTION_POINTER_UP (DOWN) -> TRUE/FALSE: return super.onInterceptTouchEvent()

This process somehow makes difficult to Pinch-In. Trouble for 2 days, found a way to improve this:

protected boolean onInterceptTouchEvent(MotionEvent me) {
    // whatever check before...

    // if one finger only
    if(me.getPointerCount() == 1) {
        return super.onInterceptTouchEvent(me);
    } else {
        // do something else
        return false;

This really does the trick.

Pete Houston

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: