初识view

时间:2023-03-09 01:24:49
初识view

屏幕左上角为原点,向右为 x 轴, 向下为 y 轴。

getLeft getTop getRight getBottom 分别返回 view 的左上右下的坐标,这里的坐标都是相对于view的父view来说的。

width = getRight() - getLeft()

height = getBottom() - getTop()

MotionEvent 中 getX/getY 返回的是相对于当前 view 左上角 x 和 y 的坐标, getRawX/getRaxY 返回的是相对于手机屏幕左上角的 x 和 y 坐标。