You could try converting to and from window coordinates using View.getLocationInWindow
this way you'll always be sure you are using the same coordinates system.
Coordinates of ImageView.getX
an Y
are relative to the parent. Canvas coordinates are relative to the view. This could cause the differences
Edit:
I assume in one place you get the coordinates of the view (using getX
and getY
). Convert these to window coordinates. Call these viewXY[]
.
When you need to use them, to draw in your canvas, also convert the top and left coordinates to window coordinates. We call these canvasXY[]
.
Now, the X
position to draw at would be viewXY[0] - canvasXY[0]
, and the Y
position would be viewXY[1] - canvasXY[1]
.