<pre name="code" class="java">/*
* 完成对左右划屏
*/
@Override
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
prev.set(event.getX(), event.getY());
break;
case MotionEvent.ACTION_UP:
break;
case MotionEvent.ACTION_MOVE:
float moveX = prev.x - event.getX();
// 左滑
if (moveX > 150 && moveX < 5000) {
// mDesignClothesBackground
// .setBackgroundResource(idClothesBackground[0]);
}
// 右滑
else if (moveX < -150 && moveX > -5000) {
// mDesignClothesBackground
// .setBackgroundResource(idClothesBackground[1]);
}
}
return false;
}
Android中Activity中左右滑动手势的监听,布布扣,bubuko.com
Android中Activity中左右滑动手势的监听