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 6333671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:30:37+00:00 2026-05-24T18:30:37+00:00

I have made my own code for my ‘implementation’ of a pinch zoom feature

  • 0

I have made my own code for my ‘implementation’ of a pinch zoom feature and it works, but it is not user-friendly at all. Often very sporadic and in general not pretty at all. I was wondering if any of you could help me out, maybe a easier way or different approach. Perhaps using the GestureListener I’m not sure how to use it though. Any help would be appreciative.

Below is my current code:

    public boolean onTouchEvent(MotionEvent event) {
        float cr, cr2 = 0.0f;
        cx = new float[2];
        cy = new float[2];
        float zx;
        final int action = event.getAction();
        switch (action) {
        case MotionEvent.ACTION_DOWN: {
            break;
        }
        case MotionEvent.ACTION_POINTER_DOWN: {
            break;
            }
        case MotionEvent.ACTION_MOVE: {
            for (int i = 0; i<event.getPointerCount(); i++) {
            if (run == true) { //see if it is the first time running program and set orig to the scale / screen res 
            Orig = scale * 800; //800 = screen res
            }
            cx[i] = event.getX(i); //get x and y for each finger
            cy[i] = event.getY(i);

            cr = (cx[0] - cx[1])*(cx[0] - cx[1]) + (cy[0] - cy[1])*(cy[0] - cy[1]); //get the distance between pointers
            cr2 = FloatMath.sqrt(cr);

            if (run == true) {
            scale = cr2/800;
            run = false;
            }
            else {
                if (scale >=  550.0f) {
                    scale = 1.0f;
                }
                if (scale <= 0.0f) {
                    scale = 1.0f;
                }
                nScale = Orig/cr2;
                scale = nScale * 0.5f;

            }
            }}  

This is probably not the best way to do this at all. Would taking the average over several events give better responses?

Thanks

  • 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-24T18:30:38+00:00Added an answer on May 24, 2026 at 6:30 pm

    See the zoom support tutorials on Sony Ericsson Developer World, hope they can give you some clue.

    • How to take advantage of the pinch-to-zoom feature in your Xperia™ 10 apps – Part 2
    • Android one finger zoom tutorial – Part 4
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made Catifier.com recently, and once the user sets their own background image,
I have made my own file type (.ddd) and I made a simple program
I have made my own sms app with a reciver. Now the emulator doesn'T
I have made a generic Observer interface and an Observable class, but can't compile
I have installation solution that have installer project (not web installer but simple installer)
I have made my own simple widget by deriving from QWidget, and am trying
I have made an application which calls the phone's contact list but i want
I have been experimenting with WPF and using a CustomControl have made my own
I have a problem with classes. I made my own class called Person. Which
I have made my own php MVC framework and have also written its documentation.

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.