title: Horizontal swipe not detected in ScrollView's parent
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/8330187/gesture-detection-and-scrollview-issue">Gesture detection and ScrollView issue</a>  </p>
  </blockquote>
  
  
  
  <p><b>EDIT:</b> question with full code asked <a href="https://stackoverflow.com/questions/8330187/gesture-detection-and-scrollview-issue">here</a>.</p>
  
  <hr>
  
  <p>I've got a layout with a child. I set a gesture listener to detect horizontal swipe on the layout. When the layout is a LinearLayout the swipe is properly detected, but when it's a ScrollView, it's not. I guess the gesture is first detected by the ScrollView and is not propagated to its ascendants, but I don't know how to solve it.</p>
  
  <p>Here's my layout:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent" android:layout_height="fill_parent"
      android:orientation="vertical"&gt;
      &lt;ImageView android:layout_width="320dp" android:layout_height="30dp"
              android:src="@drawable/header"/&gt;
      &lt;ScrollView android:layout_width="fill_parent" android:layout_height="wrap_content"&gt;
          &lt;!-- stuff --&gt;
      &lt;/ScrollView&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>I set the following listener to my layout:</p>
  
  <pre><code>class ProductGestureListener extends SimpleOnGestureListener {
  
      @Override
      public boolean onDown(MotionEvent e) {
          return true;
      }
  
      @Override
      public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
  
          final int SWIPE_MIN_DISTANCE = 120;
          final int SWIPE_MAX_OFF_PATH = 250;
          final int SWIPE_THRESHOLD_VELOCITY = 200;            
  
          try {
              if (Math.abs(e1.getY() - e2.getY()) &gt; SWIPE_MAX_OFF_PATH)
                  return false;
              if(e2.getX() - e1.getX() &gt; SWIPE_MIN_DISTANCE &amp;&amp; Math.abs(velocityX) &gt; SWIPE_THRESHOLD_VELOCITY) {                   
                  // show previous item
              }  else if (e1.getX() - e2.getX() &gt; SWIPE_MIN_DISTANCE &amp;&amp; Math.abs(velocityX) &gt; SWIPE_THRESHOLD_VELOCITY) {
                 // show next item
              }
          } catch (Exception e) {
          }           
          return false;
      }
  }
  </code></pre>