Shababb Karim
Shababb Karim

Reputation: 3713

Getting the end points of a straight line drawn by gestures in android

Using android GestureOverlayView I want to detect the two end points of the gesture drawn. In the figure below I have to detect the points drawn in circle.

gesture points

Is it possible to do so or am I using the wrong approach using GestureOverlayView?

Upvotes: 0

Views: 254

Answers (1)

Chebyr
Chebyr

Reputation: 2181

The easiest way of handling this would be to implement View.OnTouchListener

@Override
public boolean onTouch(View v, MotionEvent event)
{
    float x = event.getX();
    float y = event.getY();

    switch(event.getAction())
    {
        case MotionEvent.ACTION_DOWN:
            // A pressed gesture has started, the motion contains the initial starting location.
            break;

        case MotionEvent.ACTION_MOVE:
            // A change has happened during a press gesture (between ACTION_DOWN and ACTION_UP).
            break;

        case MotionEvent.ACTION_UP:
            //  A pressed gesture has finished, the motion contains the final release location
            // as well as any intermediate points since the last down or move event.
            break;

    }
    return false; //True if the listener has consumed the event, false otherwise.
}

Upvotes: 1

Related Questions