Open SamStenner opened 4 years ago
ViewPager2
is backed by RecyclerView
. By knowing this we could implement the following workaround:
// WARN: we use knowledge of internal structure of ViewPager2 to setup overscroll behavior
viewPager2.children.filterIsInstance<RecyclerView>().firstOrNull()?.let {
OverScrollDecoratorHelper.setUpOverScroll(it, ORIENTATION_VERTICAL)
}
For Java
:
if (viewPager2.getChildAt(0) instanceof RecyclerView) {
OverScrollDecoratorHelper.setUpOverScroll((RecyclerView) viewPager2.getChildAt(0), OverScrollDecoratorHelper.ORIENTATION_HORIZONTAL);
}
// WARN: we use knowledge of internal structure of ViewPager2 to setup overscroll behavior viewPager2.children.filterIsInstance<RecyclerView>().firstOrNull()?.let { OverScrollDecoratorHelper.setUpOverScroll(it, ORIENTATION_VERTICAL) }
Perfect!
Hi, I've noticed only the legacy viewpager is supported. Given this project has recently seen more activity, it would be great to add this. I tried implementing my own ViewPager2OverScrollDecorAdapter by following the basic structure of ViewPagerOverScrollDecorAdapter but it doesn't seem to work. Would be awesome if this could be added.