Using onScroll with viewFlipper
<p>I want to use an effect same as iPhone gallery effect. i.e when i scroll an image the next image starts appearing and moves inwards with respect to the previous image.</p>

<p>I want to use this in view flipper, Till now i can move the first image but i can't see the next image.</p>

<pre><code>public class IphoneAnimationActivity extends Activity implements
    OnGestureListener {

private static final int SWIPE_THRESHOLD_VELOCITY = 1000;
GestureDetector gestureScanner;
ViewFlipper flipper;
View v;
ImageView imageView1;
ImageView imageView2;

LayoutInflater inflate;

Animation slideOutRight;
Animation slideInLeft;
Animation slideOutLeft;
Animation slideInRight;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    flipper = (ViewFlipper) findViewById(R.id.viewFlipper1);

    inflate = getLayoutInflater();

    v = inflate.inflate(R.layout.image_view, null);

    View x = v;
    flipper.addView(x);

    slideOutRight = AnimationUtils.loadAnimation(this,
            R.anim.slide_right_out_photocards);
    slideInRight = AnimationUtils.loadAnimation(this,
            R.anim.slide_right_in_photocards);

    slideOutLeft = AnimationUtils.loadAnimation(this,
            R.anim.slide_left_out_photocards);
    slideInLeft = AnimationUtils.loadAnimation(this,
            R.anim.slide_left_in_photocards);

    gestureScanner = new GestureDetector(this);

    flipper.setOnTouchListener(new OnTouchListener() {

        public boolean onTouch(View v, MotionEvent event) {
            return gestureScanner.onTouchEvent(event);
        }
    });

}

public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
        float velocityY) {

    // right to left swipe
    if (e1.getX() - e2.getX() &gt; 0
            &amp;&amp; Math.abs(velocityX) &gt; SWIPE_THRESHOLD_VELOCITY) {
        swipeLeft();
    }
    // left to right swipe
    else if (e2.getX() - e1.getX() &gt; 0
            &amp;&amp; Math.abs(velocityX) &gt; SWIPE_THRESHOLD_VELOCITY) {
        swipeRight();
    }
    return false;
}

private void swipeRight() {

    flipper.setInAnimation(slideInRight);
    flipper.setOutAnimation(slideOutRight);

    View y = inflate.inflate(R.layout.image_view, null);
    flipper.addView(y);
    flipper.setDisplayedChild(1);
    flipper.removeViewAt(0);
    // flipper.showNext();

}

private void swipeLeft() {

    flipper.setInAnimation(slideInLeft);
    flipper.setOutAnimation(slideOutLeft);

    View y = inflate.inflate(R.layout.image_view, null);
    flipper.addView(y);
    flipper.setDisplayedChild(1);
    flipper.removeViewAt(0);
}

@Override
public boolean onDown(MotionEvent e) {
    return false;
}

@Override
public void onLongPress(MotionEvent e) {

}

@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
        float distanceY) {

    if((e1.getX() - e2.getX()) &gt; 0)
    {
        flipper.scrollBy(10, 0);            
        return true;
    }
    else if ((e1.getX() - e2.getX()) &lt; 0) {
        flipper.scrollBy(-10, 0);           
        return true;
    }
    else            
    {

    }
    return false;
}

@Override
public void onShowPress(MotionEvent e) {

}

@Override
public boolean onSingleTapUp(MotionEvent e) {

    return false;
}

public boolean onTouchEvent(MotionEvent event) {
    return gestureScanner.onTouchEvent(event);
}
</code></pre>

<p>}</p>
