Hello其他Android程序员!
我在VerticalScrollView中有一个HorizontalScrollView。
UX团队决定添加“Fling”之类的动作,以便在屏幕之间快速切换。现在,当我们尝试滚动水平滚动时,Fling就会被触发。当焦点在水平滚动时,如何防止Fling的任何想法?
由于
Ps,Fling Detector的代码:
class MyGestureListener extends GestureDetector.SimpleOnGestureListener {
@Override
public boolean onDown(MotionEvent event) {
return true;
}
@Override
public boolean onFling(MotionEvent event1, MotionEvent event2, float velocityX, float velocityY) {
// Log.d(DEBUG_TAG, "onFling: " + event1.toString() +
// event2.toString());
int dx = (int) (event2.getX() - event1.getX());
// don't accept the fling if it's too short
// as it may conflict with a button push
if (Math.abs(dx) > 250 && Math.abs(velocityX) > Math.abs(velocityY)) {
if (velocityX > 0) {
swipeLeft();
} else {
if (isMenuShowing) {
return false;
} else {
swipeRight();
}
}
return true;
} else {
return false;
}
}
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (super.dispatchTouchEvent(ev)) {
return true;
}
return mDetector.onTouchEvent(ev);
}