当用户从左到右触摸屏幕时,我可以做出检测动作的手势 但我不知道如何让图像随着那个动作一起移动 这样做的目的是在我的应用程序内部执行锁定屏幕,如iPhone锁定/解锁功能。
我想我必须做像image_swipe.setAnimate ......之类的事情 如果有人有任何想法,请告诉我。
private static final int SWIPE_MIN_DISTANCE = 120;
private static final int SWIPE_MAX_OFF_PATH = 250;
private static final int SWIPE_THRESHOLD_VELOCITY = 200;
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) {
try {
if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH)
return false;
// right to left swipe
if(e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
Toast.makeText(getApplicationContext(), "Right Swipe", Toast.LENGTH_SHORT).show();
//i would like to make ImageView "image_swipe" move along with gesture
}
} catch (Exception e) {
}
return true;
}