2012-03-25 72 views
1

我設法檢測到何時滑動某個圖像。現在,我希望圖像在用戶滑動圖像時「拉伸」(如解鎖手機)。任何方式我可以做到這一點?如何在滑動圖像時拉伸圖像

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; 
    } 

}

回答

0
+0

謝謝,但我想,當用戶掃描圖像的圖像拉伸。不知道本教程如何幫助.... – user1163234 2012-03-25 12:37:02

+0

它說如何調整畫布上的位圖大小,但你可能只想重用這個http://code.google.com/p/android-pinch/ – 2012-03-25 13:45:24

+0

或者也是本教程:http://developer.sonymobile.com/wp/2010/05/18/android-one-finger-zoom-tutorial-part-1/ – 2012-03-25 13:45:51