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

  • Home
  • SEARCH
  • 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 7754621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:21:19+00:00 2026-06-01T12:21:19+00:00

I have a custom view in my Android App that uses a ScaleGestureDetector.SimpleOnScaleGestureListener to

  • 0

I have a custom view in my Android App that uses a ScaleGestureDetector.SimpleOnScaleGestureListener to detect when the user wants to scale the view via a 2 finger pinch in or out. This works great until I tried testing on an Android 2.1 device, on which it crashes immediately because it cannot find the class.

I’d like to support the pinch zoom on 2.2+ and default to no pinch zoom <2.1. The problem is I can’t declare my:

private class ScaleListener extends ScaleGestureDetector.SimpleOnScaleGestureListener
{
    @Override
    public boolean onScale(ScaleGestureDetector detector)
    {
        MyGameActivity.mScaleFactor *= detector.getScaleFactor();

        // Don't let the object get too small or too large.
        MyGameActivity.mScaleFactor = Math.max(0.1f, Math.min(MyGameActivity.mScaleFactor, 1.0f));

        invalidate();
        return true; 
    }
}

at all on android <2.1. Is there a clever way to get around this using java reflection? I know how to test if a method exists via reflection, but can I test if a class exists? How can I have my

private ScaleGestureDetector mScaleDetector;

declared at the top of my class if the API can’t even see the ScaleGestureDetector class?

It seems like I should be able to declare some sort of inner interface like:

public interface CustomScaleDetector
{
    public void onScale(Object o);
}

And then somehow…try to extend ScaleGestureDetector depending on if reflection tells you that the class is accessible…

But I’m not really sure where to go from there. Any guidance or example code would be appreciated, let me know if it isn’t clear what I’m asking.

  • 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-06-01T12:21:20+00:00Added an answer on June 1, 2026 at 12:21 pm

    well, you can get ScaleGestureDetector source code and put in your project, make it as your own class, and use this to instead of system ScaleGestureDetector, this can avoid the android 2.2 and below version.

    here is the ScaleGestureDetector source code: http://pastebin.com/r5V95SKe

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

Sidebar

Related Questions

I have a simple custom view that is connected via outlet to a NIB.
I am making an Android app, and have created a custom view to do
I have a custom view that accepts drags. In the custom view there is
Please help me to turn off user interaction. I have a custom view which
I have a custom control/view that observes the direction of a gesture within its
I have a custom-made view that extends the View class. I would like 2
I have a custom list view that is getting data from server and changing
I have a custom 404 view defined in my Pyramid app: @view_config(context=HTTPNotFound, renderer='404.pt') def
I have a custom ViewGroup (blue background) that when touched sometime during the app's
I'm writing on a custom view in android. It uses some png's, provided as

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.