Skip to content Skip to sidebar Skip to footer

Getting All X And Y Coordinates From A Motion Event In Android

I'm currently working on my own basic drawing app. So far, my app is working well but I noticed that my motion event doesn't seem to get all the X and Y axis points that are touche

Solution 1:

This is just the way the hardware is designed. The hardware samples the touchscreen N times per second, and spits out the coordinates every time it senses a finger.

If you move faster than the screen samples, you'll have gaps in the reported data. Only thing you can do is to generate the missing points yourself by interpolating along the line between the two touches.

Solution 2:

The accepted answer isn't strictly correct, it is possible to access the touch data from the graps using the following methods:

event.getHistorySize();   // returns the number of data points stored as an intevent.getHistoricalX(int);
event.getHistoricalX(int);

Other related methods are available when there are multiple pointers (see documentation).

A good example of how this can be used in practice can be found here.

Post a Comment for "Getting All X And Y Coordinates From A Motion Event In Android"