Android Question How to get x, y coordinates of an image view placed inside panel of scrollview?

Juzer Hussain

Active Member
Licensed User
Longtime User
Hi Guys,
I have a scrollview in whose panel are labels and ImageView.When i touch(click) on any label pnlSV_Touch event fires but when i click on Imageview it wont.I want to know the x, y position of the touch point.
I tried various ways but no luck since two days.

Can anyone help please?
Juzer
 

Juzer Hussain

Active Member
Licensed User
Longtime User
Thank You Erel,
If i am calling
CallSub(Me,"pnlSV_Touch" ) it says Signature doesn't match,
Does this means CallSub will handle Subs only those without parameters? Otherwise CallSub is the best solution here.

I am trying the way you said though.

Juzer
 
Upvote 0

Juzer Hussain

Active Member
Licensed User
Longtime User
When I click on ImageView, parent panel's touch event is not firing.It is firing for labels though as i said earlier.
So from inside ImageView's Click event i tried calling CallSub(Me, "pnlSV_Touch") but it would say Signatures don't match
If i add null parameters it doesnt help because position X,Y are in the parameters itself as
pnlSV_Touch(ViewTag As Object, Action As Int, X As Float, Y As Float, MotionEvent As Object) As Boolean
I want to invoke Touch event inside ImageView Click to save X,Y in global variable, to use it further in ImageView click event
Hope i am clear Erel.
Juzer
 
Upvote 0

Juzer Hussain

Active Member
Licensed User
Longtime User
You can call it directly. You don't need to use CallSub:
B4X:
pnlSV_Touch(...)

It is not possible to call pnlSV_Touch() as i dont know the parameters(X,Y) I am calling pnlSV_Touch to get these very values in the first place.

I did the old way as suggested by you in earlier thread, Placed a transparent panel covering everything and .....
I did not want to place another big panel therefore wanted to use pnlSV_Touch method.
I had tried it earlier but had forgotten to pass Return=False at end in Touch event due to which it didn't work earlier.
It is working now.If you can suggest a better method it will be good.

Thank You Erel

Juzer
 
Upvote 0
Top