ViewPager2 is the replacement of ViewPager, addressing most of its predecessor's pain-points, including right-to-left layout support, vertical orientation and modifiable Fragment collections.
New features
- Comparing to its predecessor
android.support.v4.view.ViewPager
(VP1): - Right-to-left (RTL) layout support
- Vertical orientation support
notifyDataSetChanged
fully functional (VP1 bugs addressed)
API changes
FragmentStateAdapter
replacesFragmentStatePagerAdapter
RecyclerView.Adapter
replacesPagerAdapter
registerOnPageChangeCallback
replacesaddPageChangeListener
Known issues
- clipToPadding
- no fakeDrag
- JavaDoc
- nested scrolling parallel to orientation
- no offscreen limit control
- needs better TabLayout integration
- no pageWidth setter (forced 100%/100%)
- page transformer: no hardware/software layer choice; no reverse drawing order
- keep current item visible when inserting a page before current
- keyboard navigation needs work
- FragmentStateAdapter stability / performance improvements coming