Last active
July 5, 2023 16:10
-
-
Save nolanamy/9fc31c3056e561fa22d6e3ef71630870 to your computer and use it in GitHub Desktop.
Fix for the "nested scroll in ViewPager in BottomSheet" issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) | |
} | |
} |
@monusk111 did you put it in the correct package? See lines 1 & 2:
// must be in this package to have access to `nestedScrollingChildRef`
package com.google.android.material.bottomsheet
so cooooooooooool !!!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, actually nestedScrollingChildRef variable cannot be accessed from derived class as it is declared default in BottomSheetBehaviour class.