سؤال

I can make a gesture which detects a movement when the user touches the screen from left to right.
But I don't know how to make the image move along with that movement.
The purpose of this is to do a lock screen inside my application like the iPhone lock/unlock feature.

I guess I have to do something like image_swipe.setAnimate... or something.
If anyone has any idea, please let me know.

 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;
    }
هل كانت مفيدة؟

المحلول

See the below link, it may help you. The image movement when you swipe (onFling) the screen is available in this example.

CoverFlow Widget Example

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top