Skip to content

Instantly share code, notes, and snippets.

@nolanamy
Last active July 5, 2023 16:10
Show Gist options
  • Save nolanamy/9fc31c3056e561fa22d6e3ef71630870 to your computer and use it in GitHub Desktop.
Save nolanamy/9fc31c3056e561fa22d6e3ef71630870 to your computer and use it in GitHub Desktop.
Fix for the "nested scroll in ViewPager in BottomSheet" issue
// must be in this package to have access to `nestedScrollingChildRef`
package com.google.android.material.bottomsheet
import android.content.Context
import android.util.AttributeSet
import android.view.View
import androidx.coordinatorlayout.widget.CoordinatorLayout
import java.lang.ref.WeakReference
class ViewPagerBottomSheetBehavior<V : View>(context: Context, attrs: AttributeSet?) : BottomSheetBehavior<V>(context, attrs) {
override fun onStartNestedScroll(coordinatorLayout: CoordinatorLayout, child: V, directTargetChild: View, target: View, axes: Int, type: Int): Boolean {
nestedScrollingChildRef = WeakReference(target)
return super.onStartNestedScroll(coordinatorLayout, child, directTargetChild, target, axes, type)
}
}
@aWhalefall
Copy link

so cooooooooooool !!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment