title: Android: How to make Swipe screen Navigation comfortable
body: <p>I am using Gesture Listner to acheive Swipe screen navigation. But it is not so comfortable that I need to swipe multiple time to navigate to next or previous screen.  What are the proper values for Velocity, Off path and Min Distance.</p>
  
  <p>Please find below is my code:</p>
  
  <pre><code>private static final int SWIPE_MIN_DISTANCE = 50;
  private static final int SWIPE_MAX_OFF_PATH = 300;
  private static final int SWIPE_THRESHOLD_VELOCITY = 200;
  
  class MyGestureDetector extends SimpleOnGestureListener {
      @Override
      public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
          try {
              if (Math.abs(e1.getY() - e2.getY()) &gt; SWIPE_MAX_OFF_PATH)
                  return false;
              // right to left swipe
              if(e1.getX() - e2.getX() &gt; SWIPE_MIN_DISTANCE &amp;&amp; Math.abs(velocityX) &gt; SWIPE_THRESHOLD_VELOCITY) {
                  viewFlipper.setInAnimation(slideLeftIn);
                  viewFlipper.setOutAnimation(slideLeftOut);
                  viewFlipper.showNext();    
                  configDisplay();
              }  else if (e2.getX() - e1.getX() &gt; SWIPE_MIN_DISTANCE &amp;&amp; Math.abs(velocityX) &gt; SWIPE_THRESHOLD_VELOCITY) {
                  viewFlipper.setInAnimation(slideRightIn);
                  viewFlipper.setOutAnimation(slideRightOut);
                  viewFlipper.showPrevious();
                  configDisplay();
              }
          } catch (Exception e) {
              // nothing
          }
          return false;
      }
  }
  </code></pre>