0

Is there a way to create a new object from a MotionEvent object that extract only the X axis movement (gesture) ?

@Override
public boolean onTouchEvent(MotionEvent event) {
MotionEvent xMotionEvent = filterYMotion(event);
return super.onTouchEvent(xMotionEvent);
}

Thanks.

M'hamed
  • 2,508
  • 3
  • 24
  • 41

2 Answers2

0

You could use this code to only extract the x value:

event.getX();
Magakahn
  • 498
  • 9
  • 31
0
@Override
    public boolean onTouchEvent(MotionEvent event) {
        Matrix matrix = new Matrix();
        matrix.setScale(1, 0);
        event.transform(matrix);
        return super.onTouchEvent(event);
    }
M'hamed
  • 2,508
  • 3
  • 24
  • 41