How are coordinates determined in Android onTouchEvent MotionEvent?

I am wondering what is the origin point, i.e. (0, 0) coordinates in MotionEvent when you tap or move around the screen in Android? I know that getRawX () and getRawY () get common screen coordinates. But I would like to know the starting point for getX () and getY ().

Is it based on the absolute top left corner of the view that works onTouchEvent (MotionEvent e)? Or is it in the upper left corner of the content in the view? those. absolute left corner of the view plus getPaddingLeft () at the x coordinate and getPaddingTop () at y.

Or is it based on some other point together?

+4
source share
1 answer

GetX () and GetY () give the coordinates relative to the upper left corner of the view that handles the touch. Note that indents and margins are part of the view itself.

0
source

Source: https://habr.com/ru/post/1387559/


All Articles