MamadTell MamadTell - 9 months ago 88
Android Question

calculateDistanceX(MotionEvent) method in intercept touch events handling

I'm new to android and trying to learn intercept touch events handling using this documentation, but i do not understand that

method at all, and the more I searched about it the less i found. I'm completely confused.

Could anyone please explain it to me?

Thanks in advance.


It says that the method calculateDistanceX() is left as an exercise for a user. One solution would be to cache the first MotionEvent and then the distance would be mFirstMotionEvent.getX() - currentMotionEvent.getX()