I have a persistent bottom sheet with a LinearLayout
that acts like a header, and a SwipeRefreshLayout
with a NestedScrollView
in it. I want to be able to drag the bottom sheet by dragging that LinearLayout
, but it does not work when nested scrolling enabled on that bottom sheet's root view.
Here's my bottom sheet layout:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/list_bottom_sheet"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:elevation="10dp"
android:nestedScrollingEnabled="true"
android:orientation="vertical"
app:behavior_hideable="false"
app:layout_behavior="AnchorSheetBehavior">
<LinearLayout
android:id="@+id/list_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:nestedScrollingEnabled="false"
android:orientation="vertical">
<!-- I want to be able to drag the bottom sheet by dragging this layout. -->
<LinearLayout
android:id="@+id/list_header_linear_layout"
android:layout_width="match_parent"
android:layout_height="@dimen/layout_list_header_height"
android:background="?selectableItemBackground"
android:baselineAligned="false"
android:clickable="true"
android:focusable="true"
android:nestedScrollingEnabled="false"
android:orientation="horizontal">
<!-- Some other views here. -->
</LinearLayout>
<!-- While the user interacting with this view, the bottom sheet should not slide. -->
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipe_to_refresh_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.core.widget.NestedScrollView
android:id="@+id/bottom_sheet_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</LinearLayout>
</FrameLayout>
To give you an overview:
1. FrameLayout # root view of the bottom sheet
2. LinearLayout # container
3. LinearLayout # header view, I want to be able to slide the bottom sheet by dragging this view
3. SwipeRefreshLayout # while interacting with this view, the bottom sheet should not slide
4. NestedScrollView
How can I achieve such behaviour?