如何在 android 中检测顺时针手势
How to detect clock-wise gesture in android
我不知道如何在 android 中检测顺时针手势。我实现了 GestureDetector.OnGestureListener
private GestureDetector= new GestureDetector(this);
@Override
public boolean onDown(MotionEvent e) {
return false;
}
@Override
public void onShowPress(MotionEvent e) {
}
@Override
public boolean onSingleTapUp(MotionEvent e) {
return false;
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
return false;
}
@Override
public void onLongPress(MotionEvent e) {
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
return false;
}
有什么想法吗?谢谢
没有内置的支持。您需要从 onTouch 事件构建它。当您使用 ACTION_MOVE 检测到触摸事件时,保存它。然后查看最后N个点,看它是否顺时针移动。如果是这样,请执行您想要的任何操作。清除 ACTION_UP.
上的点列表
为了检查一组顺时针方向的点,此处描述了一种算法:How to determine if a list of polygon points are in clockwise order?
其实我也在http://android-coding.blogspot.com/2012/03/gestures-detection-and-canvas-scale.html
找到了教程
答案基本上是使用 Google 的(大部分未记录)android.gesture 包和他们的机器学习算法对示例顺时针手势进行最佳猜测匹配。
我不知道如何在 android 中检测顺时针手势。我实现了 GestureDetector.OnGestureListener
private GestureDetector= new GestureDetector(this);
@Override
public boolean onDown(MotionEvent e) {
return false;
}
@Override
public void onShowPress(MotionEvent e) {
}
@Override
public boolean onSingleTapUp(MotionEvent e) {
return false;
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
return false;
}
@Override
public void onLongPress(MotionEvent e) {
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
return false;
}
有什么想法吗?谢谢
没有内置的支持。您需要从 onTouch 事件构建它。当您使用 ACTION_MOVE 检测到触摸事件时,保存它。然后查看最后N个点,看它是否顺时针移动。如果是这样,请执行您想要的任何操作。清除 ACTION_UP.
上的点列表为了检查一组顺时针方向的点,此处描述了一种算法:How to determine if a list of polygon points are in clockwise order?
其实我也在http://android-coding.blogspot.com/2012/03/gestures-detection-and-canvas-scale.html
找到了教程答案基本上是使用 Google 的(大部分未记录)android.gesture 包和他们的机器学习算法对示例顺时针手势进行最佳猜测匹配。