Can't find a way to remove the ViewPager2 overscroll shadow animation. I know on ViewPager, you can directly just set the overscrollMode attribute to never, however, it does not work on ViewPager2
Already tried the following
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never"/>
binding.viewPager.apply {
adapter = adapter
orientation = ViewPager2.ORIENTATION_VERTICAL
overScrollMode = ViewPager2.OVER_SCROLL_NEVER
offscreenPageLimit = if (containsVideo) 2 else 5
}
Solution
binding.viewPager2.apply {
adapter = vpAdapter
orientation = ViewPager2.ORIENTATION_VERTICAL
registerOnPageChangeCallback(pageChangeCallback)
(getChildAt(0) as RecyclerView).overScrollMode = RecyclerView.OVER_SCROLL_NEVER
}
In case anyone searching for a Java solution
View child = viewPager2.getChildAt(0);
if (child instanceof RecyclerView) {
child.setOverScrollMode(View.OVER_SCROLL_NEVER);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With