I have my custom BottomSheetBehavior:
public class CustomBehavior extends BottomSheetBehavior {
public CustomBehavior(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, View
child, View target, int dx, int dy, int[] consumed) {
super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy,
consumed);
}
}
And I use it in my xml code.
<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">
<android.support.v4.widget.NestedScrollView
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="350dp"
android:clipToPadding="true"
android:background="@android:color/holo_orange_light"
app:layout_behavior=
"com.hackspace.bottomsheetproblem.CustomBehavior">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="text"/>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
This behavior works, all nice. But in callback onNestedPreScroll
dx is always zero. Log something like this:
dx: 0, dy: -1
dx: 0, dy: -70
dx: 0, dy: -108
dx: 0, dy: -85
dx: 0, dy: -44
dx: 0, dy: -16
dx: 0, dy: 16
dx: 0, dy: 44
dx: 0, dy: 62
dx: 0, dy: 84
dx: 0, dy: 58
dx: 0, dy: 54
dx: 0, dy: 43
dx: 0, dy: 17
dx: 0, dy: -20
dx: 0, dy: -42
Actually, my goal is to make some changes in detection swipes in default BottomSheetBehavior. I need my custom behavior react only on vertical (or almost vertical) swipes, not even on almost horizontal.