title: Programmatically scroll RecyclerView with disabled vertical scrolling
body: <p>My RecyclerView has ViewPagers and buttons within it, so I cannot disable scrolling or disable all touches.</p>
  
  <p>I disable only vertical scrolling with:</p>
  
  <pre><code>recyclerView.setLayoutManager(new LinearLayoutManager(this) {
      @Override
      public boolean canScrollVertically() {
          return false;
      }
  });
  </code></pre>
  
  <p>The problem is when I try to scroll the recyclerView with code:</p>
  
  <pre><code>recyclerView.smoothScrollBy(0, 500);
  </code></pre>
  
  <p>The smoothScrollBy in android is defined as:</p>
  
  <pre><code>public void smoothScrollBy(int dx, int dy, Interpolator interpolator) {
      if (mLayout == null) {
          Log.e(TAG, "Cannot smooth scroll without a LayoutManager set. "
                  + "Call setLayoutManager with a non-null argument.");
          return;
      }
      if (mLayoutFrozen) {
          return;
      }
      if (!mLayout.canScrollHorizontally()) {
          dx = 0;
      }
      if (!mLayout.canScrollVertically()) { // &lt;--- problem
          dy = 0;
      }
      if (dx != 0 || dy != 0) {
          mViewFlinger.smoothScrollBy(dx, dy, interpolator);
      }
  }
  </code></pre>
  
  <p>Nothing happens when I call scrollBy or smoothScrollBy because canScrollVertically is false.</p>
  
  <p>Also note that if I set it to true, then scroll, then try to false, the scrollView jitters and it does not scroll completely:</p>
  
  <pre><code>layoutManager.canScrollVertically = true;
  recyclerView.smoothScrollBy(0, 500);
  layoutManager.canScrollVertically = false; // -&gt; when this line is set, the smoothScrolling stops immediately
  </code></pre>
  
  <p>I am trying to prevent the user from scrolling vertically, because I am trying to handle the vertical scrolling from code. The user should still be able to interact with other elements within the RecyclerView and be able to scroll horizontally within the RecyclerView.</p>
  
  <p>What can I try?</p>