2011-12-20 44 views
0

我可以制作一个手势,当用户从左到右触摸屏幕时,手势会检测到移动。
但我不知道如何使图像随着该运动而移动。
这样做的目的是在我的应用程序内部锁定屏幕,例如iPhone锁定/解锁功能。在滑动手势中制作一个ImageView动画

我想我必须做一些像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; 
    } 
+0

你可以发表一些代码,你如何做到这一点。谢谢! – user1163234 2012-03-25 13:41:23

回答

0

看到下面的链接,它可能会帮助你。在此示例中可以使用滑动(onFling)屏幕时的图像移动。

CoverFlow Widget Example