I have structure below
<LinearLayout>
<ViewPager>
</LinearLayout>
inside ViewPager fragment layout
<LinearLayout android:orientation=vertical>
<RecyclerView android:nestedScrollingEnabled=false />
<Button />
</LinearLayout>
But nestedScrollingEnabled doesn't work from xml. But when I execute code below in bottom sheet fragment, it works, I don't know why
try {
val field = ViewPager2::class.java.getDeclaredField("mRecyclerView")
field.isAccessible = true
(field[binding.pager] as RecyclerView).isNestedScrollingEnabled = false
} catch (e: NoSuchFieldException) {
Timber.e(e)
} catch (e: IllegalAccessException) {
Timber.e(e)
}
pager.children.find { it is RecyclerView }?.let {
(it as RecyclerView).isNestedScrollingEnabled = false
}
this code solved the problem without using reflection