title: How to change background color while swiping on an view?
body: <p>I Have an relative layout and on this relative layout I handled the swiping from right to left and from left to right events successfully using the following code.</p>
  
  <pre><code>    relativeLayout1.setOnTouchListener(new View.OnTouchListener() 
      {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
              return gesture.onTouchEvent(event);
          }
      });
  
  
  final GestureDetector gesture = new GestureDetector(getActivity(),
          new GestureDetector.SimpleOnGestureListener() {
  
              @Override
           public boolean onDown(MotionEvent e) {
                  return true;
              }
           public boolean onDoubleTap(MotionEvent e) {return true;}
           public void onLongPress(MotionEvent e) {}
           public boolean onDoubleTapEvent(MotionEvent e) {return true;}
           public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {return true;}
           public void onShowPress(MotionEvent e) {}
           public boolean onSingleTapConfirmed(MotionEvent e) {return true;}
           public boolean onSingleTapUp(MotionEvent e) {return true;}
              @Override
           public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
                  float velocityY) {
  
                  final int SWIPE_MIN_DISTANCE = 5;
                  final int SWIPE_MAX_OFF_PATH = 400;
                  final int SWIPE_THRESHOLD_VELOCITY = 100;
                  try {
                      if (Math.abs(e1.getY() - e2.getY()) &gt; SWIPE_MAX_OFF_PATH)
                          return false;
                      if (e1.getX() - e2.getX() &gt; SWIPE_MIN_DISTANCE// user slide right to left
                          &amp;&amp; Math.abs(velocityX) &gt; SWIPE_THRESHOLD_VELOCITY) {
                          Log.i("Mhd", "Right to Left");
  
                      } else if (e2.getX() - e1.getX() &gt; SWIPE_MIN_DISTANCE//user slide left to right
                          &amp;&amp; Math.abs(velocityX) &gt; SWIPE_THRESHOLD_VELOCITY) {
                          Log.i("Mhd", "Left to Right");
                      }
                  } catch (Exception e) {
  
                  }
                  return super.onFling(e1, e2, velocityX, velocityY);
              }  
          });
  </code></pre>
  
  <p>But I really need the color of relative layout change based on where my finger arrived while I am swiping on this relative layout for example when you try to call some one your android device you will swipe from left to right and you will notice that the color changes based on where your finger arrived on contact view.</p>