title: Open bottom sheet when sibling scrolling reaches the end?
body: <p>Is there any way to "forward" scroll events from one scrolling view to my bottom sheet, so that my bottom sheet begins to expand when I over-scroll the first scrolling view?</p>
  
  <p>Consider this tiny app:</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          int peekHeight = getResources().getDimensionPixelSize(R.dimen.bottom_sheet_peek_height); // 96dp
  
          View bottomSheet = findViewById(R.id.bottomSheet);
          BottomSheetBehavior&lt;View&gt; behavior = BottomSheetBehavior.from(bottomSheet);
          behavior.setPeekHeight(peekHeight);
      }
  }
  </code></pre>
  
  
  
  <pre><code>&lt;android.support.design.widget.CoordinatorLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;android.support.v4.widget.NestedScrollView
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
  
          &lt;!-- LinearLayout holding children to scroll through --&gt;
  
      &lt;/android.support.v4.widget.NestedScrollView&gt;
  
      &lt;View
          android:id="@+id/bottomSheet"
          android:layout_width="300dp"
          android:layout_height="400dp"
          android:layout_gravity="center_horizontal"
          app:layout_behavior="android.support.design.widget.BottomSheetBehavior"/&gt;
  
  &lt;/android.support.design.widget.CoordinatorLayout&gt;
  </code></pre>
  
  <p>Out of the box, this works just fine. I see 96dp worth of my bottom sheet, and I can swipe it up and down as normal. Additionally, I can see my scrolling content, and I can scroll it up and down as normal.</p>
  
  <p><a href="https://i.stack.imgur.com/TgybIm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/TgybIm.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/MBAmCm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/MBAmCm.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/rVbABm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/rVbABm.png" alt="enter image description here"></a></p>
  
  <p>Let's assume I'm at the state shown in the second image. My <code>NestedScrollView</code> is scrolled all the way to the bottom and my bottom sheet is collapsed. I'd like to be able to swipe upwards on the <code>NestedScrollView</code> (<em>not</em> on the bottom sheet) and, since it can't scroll any farther, have that swipe gesture <em>instead</em> be sent to the bottom sheet, so that it begins to expand. Basically, have the app behave as though my gesture had been performed on the bottom sheet, not the scroll view.</p>
  
  <p>My first thought was to look at <code>NestedScrollView.OnScrollChangeListener</code>, but I couldn't get that to work since it stops being triggered at the boundaries of the scrolling content (after all, it listens for scroll <em>changes</em>, and nothing's changing when you're at the edges).</p>
  
  <p>I also took a look at creating my own subclass of <code>BottomSheetBehavior</code> and trying to override <code>onInterceptTouchEvent()</code>, but ran into trouble in two places. First, I only want to capture events when the sibling scroll view is at the bottom, and I could do that, but I was now capturing <em>all</em> events (making it impossible to scroll the sibling back up). Second, the <code>private</code> field <code>mIgnoreEvents</code> inside <code>BottomSheetBehavior</code> was blocking the bottom sheet from actually expanding. I can use reflection to access this field and prevent it from blocking me, but that feels evil.</p>
  
  <p>Edit: I spent some more time looking into <code>AppBarLayout.ScrollingViewBehavior</code>, since that seemed to be pretty close to what I wanted (it converts swipes on one view into resizing on another), but that appears to manually set the offset pixel by pixel, and bottom sheets don't quite behave that way.</p>