Inside a parent nested scroll container like bottom sheet, I want one child lazy list to not part in nested scrolling(i.e., it should not ask parent prescroll and consume all the scroll event). Is this possible to do in compose?
Atul Gupta
11/26/2023, 7:24 PM
I was able to do it in view world using the code below
Copy code
class BottomSheetExcludedNestedScrollViewIds<T : View> @JvmOverloads constructor(
context: Context,
attrib: AttributeSet? = null,
) : BottomSheetBehavior<T>(context, attrib)
{
override fun onStartNestedScroll(
coordinatorLayout: CoordinatorLayout,
child: T,
directTargetChild: View,
target: View,
axes: Int,
type: Int,
): Boolean
{
return if (target.id in listOfExcludedNestedScrollViewIds)
{
// excluding the nested scroll for few ids present in `listOfExcludedNestedScrollViewIds`
false
}
else
{
super.onStartNestedScroll(
coordinatorLayout,
child,
directTargetChild,
target,
axes,
type
)
}
}
/**
* List of ids for which nested scroll will be ignored
*/
val listOfExcludedNestedScrollViewIds = arrayListOf<Int>()
}
Tried it seems to work but this lib is 0.1.0 version and also uses private window api using reflection ðŸ˜
🙀 1
m
MR3Y
11/30/2023, 11:16 AM
Haven't dived into its internals yet (as the library is still very new indeed), but yeah I guess this is basically the tradeoff here as apparently there is no public API or an easy way to do this.