title: Android - how to disable a ScrollView and all children
body: <ul>
  <li>edited for clarity</li>
  </ul>
  
  <p>I feel like this question already has an answer, but I can't find one.</p>
  
  <p>I have a ScrollView in my layout, and it contains a variety of clickable views.</p>
  
  <p>Under a specific condition I would like to disable clicks and events for the ScrollView and ALL of its children.</p>
  
  <p>The following have not been helpful:</p>
  
  <pre><code>ScrollView.setEnabled(false)
  ScrollView.setClickable(false)
  ScrollView.setOnTouchListener(null)
  </code></pre>
  
  <p>As well as:</p>
  
  <pre><code>(parent view of the ScrollView).requestDisallowInterceptTouchEvent()
  </code></pre>
  
  <p>I have created a custom ScrollView with the following code:</p>
  
  <pre><code>public class StoppableScrollView extends ScrollView
  {
      private static boolean stopped = false;
  
      public StoppableScrollView(Context context)
      {
          super(context);
      }
  
      public StoppableScrollView(Context context, AttributeSet attrs)
      {
          super(context, attrs);
      }
  
      @Override
      public boolean onInterceptTouchEvent(MotionEvent ev)
      {
          if(stopped)
          {
              return true;
          }
          else
          {
              super.onInterceptTouchEvent(ev);
              return false;
          }
      }
  
      @Override
      public boolean onTouchEvent(MotionEvent ev)
      {
          if(stopped)
          {
              return true;
          }
          else
          {
              super.onTouchEvent(ev);
              return false;
          }
      }
  
      public static void setStopped(boolean inBool)
      {
          stopped = inBool;
      }
  
      public static boolean getStopped()
      {
          return stopped;
      }
  }
  </code></pre>
  
  <p>Using only onTouchEvent() will stop the scrolling, but not the clicking of child views.</p>
  
  <p>Using only onInterceptTouchEvent() makes it such that when clicks work scrolling does not, and vice versa.</p>
  
  <p>Using both onTouchEvent() and onInterceptTouchEvent() successfully stops unwanted clicks on child views when stopped is 'true' but it also disables scrolling regardless of the state of stopped.</p>
  
  <p>Is there an easier way to get this behaviour, or is there a way to modify the StoppableScrollView class so that it will handle these touch events properly?</p>