title: How can I prevent focus changes on scroll/fling for a HorizontalScrollView?
body: <p>When an EditText or other focusable View exists inside of a <code>HorizontalScrollView</code> it gets focused when flinging. </p>
  
  <p>Digging into source, you can see why:</p>
  
  <pre><code>    /**
       * Fling the scroll view
       *
       * @param velocityX The initial velocity in the X direction. Positive
       *                  numbers mean that the finger/cursor is moving down the screen,
       *                  which means we want to scroll towards the left.
       */
      public void fling(int velocityX) {
          if (getChildCount() &gt; 0) {
              int width = getWidth() - mPaddingRight - mPaddingLeft;
              int right = getChildAt(0).getWidth();
  
              mScroller.fling(mScrollX, mScrollY, velocityX, 0, 0,
                      Math.max(0, right - width), 0, 0, width/2, 0);
  
              final boolean movingRight = velocityX &gt; 0;
  
              View currentFocused = findFocus();
              View newFocused = findFocusableViewInMyBounds(movingRight,
                      mScroller.getFinalX(), currentFocused);
  
              if (newFocused == null) {
                  newFocused = this;
              }
  
              if (newFocused != currentFocused) {
                  newFocused.requestFocus(movingRight ? View.FOCUS_RIGHT : View.FOCUS_LEFT);
              }
  
              postInvalidateOnAnimation();
          }
      }
  </code></pre>
  
  <p>Some of the suggested workarounds for this involve using the following attributes:</p>
  
  <pre><code>   android:descendantFocusability="beforeDescendants"
     android:focusable="true"
     android:focusableInTouchMode="true"
  </code></pre>
  
  <p>This works well for some simple cases, but it can lead to odd behavior if your <code>HorizontalScrollView</code> is nested in another <code>ScrollView</code> (e.g the outer scroll view will jump to the container now being focused). </p>
  
  <p>Also from experience trying this solution, it can require adding it to <em>every</em> parent container containing a focusable view (e.g. <code>EditText</code>). If you have any sort of complex focus logic going on, this all can get out of hand. </p>
  
  <p>Are there any other workaround solutions?</p>