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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:18:01+00:00 2026-06-09T12:18:01+00:00

Im trying to find the co-ordinates were a user is touching inside an imageview

  • 0

Im trying to find the co-ordinates were a user is touching inside an imageview only.

So far i have managed to do this by the following code:

    img = (ImageView) findViewById(R.id.image);
    img.setOnTouchListener(new OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            x = (int) event.getX();
            y = (int) event.getY();
            int[] viewCoords = new int[2];
            img.getLocationOnScreen(viewCoords);
            int imageX = (int) (x - viewCoords[0]); // viewCoods[0] is the X coordinate
            int imageY = (int) (y - viewCoords[1]); // viewCoods[1] is the y coordinate
            text.setText("x:" +x +"y"+y);

            return false;
        }
    });

However this is onTouchListener which means it only finds the co-ordinates after each touch, what i want to do is create it so that it constantly finds co-ordinates while the user moves their finger around the imageview. I achieved this for the whole screen by this code:

@Override
public boolean onTouchEvent(MotionEvent event) {
    x = (float)event.getX();
    y = (float)event.getY();
    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
        case MotionEvent.ACTION_MOVE:
        case MotionEvent.ACTION_UP:
    }



    text.setText("x:"+ x +" y:" +y);

return false;
}

However I don’t know how to make this code work inside the imageview only.

enter image description here

  • 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-09T12:18:02+00:00Added an answer on June 9, 2026 at 12:18 pm

    Your problem is that you return false at the end of the onTouch event.

    When you return false, you are telling the OS that you are no longer interested in any events related to this particular gesture, so it stops informing your view of future activity (such as ACTION_MOVE and ACTION_UP).

    Return true to onTouchEvent, and you will continue to receive a stream of events as long as the finger is held to the screen, and a final event when it is released.

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

Sidebar

Related Questions

In trying to find the possible cause of an exception, I'm following a code
Trying to find the best way to write this SQL statement. I have a
I'm trying to find the assembly of a page request during runtime. I have
I'm trying find a way to have PHP to indicate to the browser that
Trying to find some information on this but am unable to get any results
Trying to find out what permissions user '_www' has on my OS X server.
I'm trying to use the geocoder to get co-ordinates for the following address: 1945
I am trying find out what is postgres can handle safely inside of transaction,
I am trying find lat & long from user given address, for that i
I'm trying find a way to create mysql users with passwords using php code,

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.