I managed to detect when I swipe a certain image. Now I want the image to "stretch" (like unlocking phone) when the user slides the image. Any way I can do this?
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;
}
}
Apply matrix transformations.
Here is a very good tutorial from Sony: http://developer.sonymobile.com/wp/2011/06/27/how-to-scale-images-for-your-android%E2%84%A2-application/