tags:

views:

67

answers:

3

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

A: 
@Override
    public boolean onTouch(View v, MotionEvent event) {
       int x = event.getX();
       int y = event.getY();
       return true;
    }
Sephy
Thank You Sephy
Alex
A: 

You can implement a Gesture deductor and on its onfling event you get two parameters from MotionEvent class. You can get your x and y coordinates from them. Look out for this post for more details

http://stackoverflow.com/questions/937313/android-basic-gesture-detection

Rahul
Thank You Rahul
Alex
the onTouch event is a better way of doing this.
stealthcopter
+2  A: 
@Override
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:
    }
}
yaourt
Thank you Yaourt
Alex