3

I have an ImageView with an image loaded,

I want that when the user clicks in a point of the image, another little image(used as pin) is overlapped in this point and the coordinates of the point are returned.

But I haven't idea of how could I do this.

Asgard
  • 388
  • 1
  • 5
  • 16

2 Answers2

1

Try this,

It will help you to place image based on the co-ordinates. So it can be overlapped

Link 1

Community
  • 1
  • 1
RajeshVijayakumar
  • 10,281
  • 11
  • 57
  • 84
1

To place a image at a certain coordinates you will have to draw the image on the canvas . To get the coordinates of the touch event use the following code:

@Override
    public void onTouchEvent(MotionEvent event) {
        if (event.getAction() == MotionEvent.ACTION_MOVE) {
            mTouchX = event.getX();
            mTouchY = event.getY();//stores touch event
        } else {
            mTouchX = -1;
            mTouchY = -1;
        }
        super.onTouchEvent(event);
    }

Here is the code for drawing the image on canvas Image in Canvas with touch events hope it helps.

Community
  • 1
  • 1
Rachita Nanda
  • 4,509
  • 9
  • 42
  • 66