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 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 am developing an app that uses a custom view where a bitmap is
I have an app that sends files with custom file extensions via email that
I am making an Android app, and have created a custom view to do
I have to build a more complex custom view in Android. The final layout
I have a custom View that I would like to embed in an WebView.
I have a custom view (inherited from UIView ) in my app. The custom
I have a custom view, that has page and block. But the problem when
I have a custom view that accepts drags. In the custom view there is
I have a custom ViewGroup (blue background) that when touched sometime during the app's
I have a custom view that extends LinearLayout, with these constructors: public class CustomView

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.