문제

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.

도움이 되었습니까?

해결책 2

@Override
    public boolean onTouchEvent(MotionEvent event) {
        Matrix matrix = new Matrix();
        matrix.setScale(1, 0);
        event.transform(matrix);
        return super.onTouchEvent(event);
    }

다른 팁

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

event.getX();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top