当我滑动某个图像时,我设法检测到。现在,当用户滑动图像时,我希望图像能够“拉伸”(例如解锁手机)。我有什么办法可以做到这一点?
image.setOnTouchListener(gestureListener);
}
class MyGestureDetector extends SimpleOnGestureListener
{
@Override
public boolean onDown(MotionEvent e)
{
// TODO Auto-generated method stub
//return super.onDown(e);
return true;
}
@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(e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY)
{
Toast.makeText(Swipe2Activity.this, "Left Swipe", Toast.LENGTH_SHORT).show();
}
else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY)
{
Toast.makeText(Swipe2Activity.this, "Right Swipe", Toast.LENGTH_SHORT).show();
}
}
catch (Exception e)
{
// nothing
}
return false;
}
}