继承gallery并重写onFling如下,即可
/**
* 一次滑动只滚动一张图片
*/
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) {
if (velocityX > 0) {
// 往左边滑动
super.onKeyDown(KeyEvent.KEYCODE_DPAD_LEFT, null);
} else {
// 往右边滑动
super.onKeyDown(KeyEvent.KEYCODE_DPAD_RIGHT, null);
}
return false;
}