Hi everyone,

I noticed when developing on an HTC Magic (G2) that when moving your
finger on the screen the location of the touch events trail your
finger pretty significantly. To test this I wrote a very simple app
that just draws a rectangle where you're touching. Even in this simple
case the rectangle can trail the finger on screen by a fair amount.
Here's the View that handles the touches and draws the rectangle:

public class TouchTestView extends View {
    private float x;
    private float y;
    private Paint paint = new Paint();
    public static final int SIZE = 40;

    public TouchTestView(Context context) {
        super(context);
        paint.setColor(Color.RED);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                x = event.getX();
                y = event.getY();
                invalidate();
                return true;
            case MotionEvent.ACTION_MOVE:
                x = event.getX();
                y = event.getY();
                invalidate();
                return true;
            case MotionEvent.ACTION_UP:
                x = -1;
                y = -1;
                invalidate();
                return true;
        }
        return super.onTouchEvent(event);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        canvas.drawRect(x - SIZE, y - SIZE, x + SIZE, y + SIZE,
paint);
    }
}

So my question is: Is there a significant built in time delay between
the generation of the touch event and it's reception in the running
activity? If so, is there any tricks or methods to get those events in
a faster or more direct way? In our application the delay is causing
some pretty unfortunate performance results.

Thanks for any advice or help,
Matt
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to