Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7009121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:49:21+00:00 2026-05-27T21:49:21+00:00

I am creating a View that needs to consume pretty much any gesture going.

  • 0

I am creating a View that needs to consume pretty much any gesture going. To do this I created a ScaleGestureDetector and a GestureDetector. I also created one listener class and realized I could have it implement every interface I needed; so I did. This makes total sense for OnGestureListener and OnDoubleTapListener because they come from the same class, but:

  • Will the ScaleGestureDetector expect its own listener class?
  • If it’s happy with the same class, will it expect its own object?
  • Conversely, do I NEED to use the same listener with both detectors?

Experiment has confirmed the following:

  • You can indeed use one listener class, but
  • ScaleGestureDetector and GestureDetector can annoy each other if they consume the same event. However
  • It seems you can prevent this mutual irking by always calling the scale detector FIRST and then checking its isInProgress() method before running the regular detector:

    public boolean onTouchEvent(MotionEvent event) {
    //let the ScaleGestureDetector try first
        mScaleDetector.onTouchEvent(event);
    //if isInProgress() returns true then it's consuming the event
        if(mScaleDetector.isInProgress()) return true;
    //if isInProgress() returns false it isn't consuming the event
    //it's therefore safe to pass it to the regular detector
        mPrimaryDetector.onTouchEvent(event);
        return true;
    }
    
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:49:22+00:00Added an answer on May 27, 2026 at 9:49 pm

    ScaleGestureDetector and GestureDetector can annoy each other if they
    consume the same event. However It seems you can prevent this mutual
    irking by always calling the scale detector FIRST and then checking
    its isInProgress() method before running the regular detector

    Personally, I have not found any issues by letting them both handle the same touch event.

    The android GestureDetector has a constructor which takes a boolean ignoreMultiTouch. Setting ignoreMultiTouch to true will ensure that the GestureDetector touch event processing ignores any mutitouch events. (Android actually sets ignoreMultiTouch to true if the target API level is >= Froyo, so you probably won’t need to explicitly set it.)

    If you only call mPrimaryDetector.onTouchEvent(event), when mScaleDetector.isInProgress() returns false, you will incorrectly get a long press event. The reason is the GestureDetector has the following code in its onTouchEvent(MotionEvent ev) to ensure it does not conflict with multitouch gestures:

    case MotionEvent.ACTION_POINTER_DOWN:
      if (mIgnoreMultitouch) {
        // Multitouch event - abort.
        cancel();
      }
      break;
    

    cancel() will do what it says and cancel any single touch gestures. (If you’re really curious you can look at that GestureDetector code yourself; it actually uses a handler to send/remove messages).

    Hope this helps anyone who was having the same issues I was.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a web-browser type app (using a web view object) that needs to
I'm creating a custom ViewController. This VC needs to load some data that is
I have such view that handles user registration. After creating new user i want
I am creating a nav-based app with a view that floats at the bottom
I am creating an SQL view for a file that strips out the spaces
I am creating an SDK for a client that includes predefined view controllers. What
I'm creating an app that needs three separate search boxes. I want them to
I am creating a web application for my company that needs to deal with
i am coding a pretty large intranet based web system that needs to support
I'm creating a class that needs to parse user contact info to determine if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.