When reading the getX()
and getY()
values for a series of onTouch
events, I find that the ACTION_MOVE
events will return the ACTION_DOWN
coordinates until a certain distance threshold from these coordinates has been passed. From then onwards the correct coordinates will always be returned.
Steps to reproduce:
- Create a new application project with a default activity
Add the following method to the default activity:
@Override public boolean onTouchEvent(MotionEvent event) { Log.i("getXYDelay", "(x,y)=("+event.getX() + "," + event.getY() + ")"); return super.onTouchEvent(event); }
Run on a device and watch logcat as you touch and drag
You should see that, on every touch and drag, the getX()
/getY()
results only start changing after your finger has moved half a centermeter or so, and from then on it is accurate.
I can see how for a lot of circumstances this would be helpful, but it causes issues in the application that I'm writing, so:
- Is this initial lag over-ridable? Or can it be bypassed?
- Is it device specific?
Ideally I'd like to turn it off for a single OpenGL surface view.
Note:
- It doesn't happen when I use a Samsung Note SPen.
- The same happens with
getRawX()/getRawY()
. - This doesn't happen on an emulator so is presumably coming from the hardware touch drivers.
Update: I'm assuming this is caused by hardware drivers or a similar level, and as such is beyond the application's control. I've also attempted to post this to the android developer group, but after several weeks it seems the moderators are still sitting on my post.