Alex Alex - 1 year ago 66
Android Question

How to get the Touch position in android?

I need to get the touch begin position (X, Y) , touch move position and touch end position of the screen in android.

Answer Source
public boolean onTouchEvent(MotionEvent event) {
    int x = (int)event.getX();
    int y = (int)event.getY();
    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
        case MotionEvent.ACTION_MOVE:
        case MotionEvent.ACTION_UP:
return false;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download