Difference between MotionEvent.getRawX and MotionEvent.getX

后端 未结 2 1145
不知归路
不知归路 2020-12-01 03:33

I would like to know The difference between MotionEvent.getRawX and MotionEvent.getX in android as one is numeric and the other is float?Whats the

相关标签:
2条回答
  • 2020-12-01 03:46

    MotionEvent will sometimes return absolute X and Y coordinates relative to the view, and sometimes relative coordinates to the previous motion event.

    getRawX() and getRawY() that is guaranteed to return absolute coordinates, relative to the device screen.

    While getX() and getY(), should return you coordinates, relative to the View, that dispatched them.

    0 讨论(0)
  • 2020-12-01 04:11

    =>

    rawX = motionEvent.getX() + touchableButton.getX() + layout3.getX() + layout2.getX();
    
    0 讨论(0)
提交回复
热议问题