I have a linear layout that has an image in it I am trying to get the touch event coordinates of the image relative to the parent that contains it. Do you know I can I get these? getX and getY are returning position relative to self
The MotionEvent class has methods getX() to get X touch point corresponding to that view and getRawX() to get X touch point corresponding to screen.
So to get X touch point corresponding to parent you can get that by a simple calculation:
view.getLeft() + motionEvent.getX()
The getLeft() returns Left position of this view relative to its parent
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With