Android Question How to place a picture over ImageView on X,Y Touch coordinates.

ThiagoRodrigues

Member
Licensed User
Longtime User
Hi,

I have an ImageView and a Panel over it to GetPixel of the image.

I would like to add a crosshair or something to show the point where the user touched it.

How can I add another image over the ImageView at the coordinates of the touch event?

Something like the picture attached (1 and 3 are secondary images over the main one).

Best Regards,
 

Attachments

  • touch.jpg
    touch.jpg
    3.9 KB · Views: 323

walterf25

Expert
Licensed User
Longtime User
Hi,

I have an ImageView and a Panel over it to GetPixel of the image.

I would like to add a crosshair or something to show the point where the user touched it.

How can I add another image over the ImageView at the coordinates of the touch event?

Something like the picture attached (1 and 3 are secondary images over the main one).

Best Regards,
you can use the panel, whenever you touch on the panel, you can use the touch event to detect the coordinates where you are touching.
and inside the touch event you can add the picture
B4X:
Sub panel1_Touch (Action As Int, X As Float, Y As Float)
    imageview1.Left = X
    imageview1.Top = Y
    imageview1.Visible = True
End Sub

just an idea, you are going to have to do the math to place the imageview in the center of your x and y coordinates.

hope this gets you started.
 
Upvote 0

ThiagoRodrigues

Member
Licensed User
Longtime User
Thanks Walterf25, but I think I can´t do this way... because ImageView1 already has a picture, and it can´t be changed or modified.
I need to place a second picture over it (overlay) at the touch coordinates...
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
Thanks Walterf25, but I think I can´t do this way... because ImageView1 already has a picture, and it can´t be changed or modified.
I need to place a second picture over it (overlay) at the touch coordinates...

You can place a transparent panel over your imageview, Imageview does not have a touch event, only a click event.
 
Upvote 0
Top