Search code examples
androidimagepixelpointsmarkers

Is there a way to calculate the pixel length by marking two points on an image using android studio?


I am working on a project which requires to get the pixel length between two points on an image. I am doing this using android studio. The pixel length must not change when zooming. How can I achieve this using android studio? Thanks in advance!


Solution

  • implement the GestureDetector.onListener interface inyour activity or fragment.

    Inside onDown function , you will receive an MotionEvent object.

    you can get y coorfinate of the tapped poiny by : motioneventObj.getX() and y coordiante as getY().

    assign these values to variables to be used in your program further when the next time onDown callback is called.

    How to implenet he interface.. you wil find out here :

    https://developer.android.com/training/gestures/detector