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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:09:44+00:00 2026-05-26T16:09:44+00:00

Background: I have an ImageView that I’ve modified to be scrollable (drag) and zoom-able

  • 0

Background:
I have an ImageView that I’ve modified to be scrollable (drag) and zoom-able (pinch zoom). I used the exact technique mentioned in the “Hello, Android” 3rd edition book that can also be found here. This technique uses matrix transformation to handle both scrolling and zooming.

My Problem:
When a user taps on the image, I want the coordinates of that tap in relation to the image itself, regardless of how the image has been scrolled or magnified. For instance, if my image is 1000×2000 and I scroll and zoom the image. Then I tap on the image at a certain point, I want to know what that point is in relation to the 1000×2000, not just the screen area. How can I do this?

  • 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-26T16:09:45+00:00Added an answer on May 26, 2026 at 4:09 pm

    I found a solution to this using bits of info I’ve pieced together from other questions on this site. To give back to the community, I figured it was only right to share what I learned. Hope this helps somebody:

    // Get the values of the matrix
    float[] values = new float[9];
    matrix.getValues(values);
    
    // values[2] and values[5] are the x,y coordinates of the top left corner of the drawable image, regardless of the zoom factor.
    // values[0] and values[4] are the zoom factors for the image's width and height respectively. If you zoom at the same factor, these should both be the same value.
    
    // event is the touch event for MotionEvent.ACTION_UP
    float relativeX = (event.getX() - values[2]) / values[0];
    float relativeY = (event.getY() - values[5]) / values[4];
    

    Thanks to these sources:
    source 1 and source 2

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

Sidebar

Related Questions

in a RelativeLayout I have an Imageview that serves as the background of the
If i have an ImageView that fills the screen. The ImageView background is set
Background: I have a kubuntu laptop right now that I can't use wirelessly, i.e.
Background: we have an application that generates reports from HTML (that may or may
I have an ImageView object that I'm setting the android:src=@drawable/some_xml_file instead of a standard
I have a custom ListView and an ImageView that I'm trying to use as
I have four imageview in sequence on a screen setting with custom background images.
how can I change the background of an ImageView from java? I have an
I have an imageview, which uses matrix to scale/drag an image. Now I want
I have an ImageView that I set to center inside the LinearLayout of a

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.