RecyclerView (horizontal) nested in BottomSheet to prevent vertical scrolling

I have RecyclerView, using orientation LinearLayoutManagerc HORIZONTAL, nested inside a FrameLayoutwith BottomSheet Behavior.

When you try to drag vertically through RecyclerView, it BottomSheetdoes not respond to the drag event. Presumably this is due to the fact that vertical scrolling is disabled for LayoutManagerhorizontal orientation.

I tried to override LinearLayoutManager.canScrollVertically()and return true. Such work. If you pull vertically very carefully, answer BottomSheet. However, as soon as any horizontal movement is involved, it BottomSheetstops responding to vertical drag events.

I am not sure if this is the right approach canScrollVertically()- this, of course, does not seem to be right from the point of view of UX.

I also noticed that if I use ViewPager, and not RecyclerViewwith a horizontally oriented LayoutManager, it BottomSheetresponds to events of a vertical swipe as desired.

Is there any other method LayoutManager, RecyclerView, BottomSheet Behavioror something else that can help to spread the events on the vertical scroll BottomSheet Behavior?

Here is an example of a problem here:

https://github.com/timusus/bottomsheet-test (The problem can be reproduced using commit # f59a7031)

Just expand the first bottom sheet.

+6
source share
1

? FrameLayout. BottomSheet CoordinatorLayout. BottomSheet CoordinatorLayout , CoordinatorLayout.

RecyclerView BottomSheet? CoordinatorLayout. : RecyclerView , NestedScrollingParent NestedScrollingChild. : NestedScrollView

, fragment_sheetX.xml :

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#fff"
    android:orientation="vertical"
    android:fillViewport="true">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

</android.support.v4.widget.NestedScrollView>

, android:fillViewport="true" , RecyclerView .

. ? RecyclerView . ? recyclerView.setNestedScrollingEnabled(false);, .

Btw: MultiSheetView - UX.

+7

Source: https://habr.com/ru/post/1017106/


All Articles