MyViewPager2 icon indicating copy to clipboard operation
MyViewPager2 copied to clipboard

ViewPager2 with RecyclerView and TabLayout

MyViewPager2

This sample shows how to use ViewPager2 with RecyclerView and TabLayout (Mediator), for manage your own state saving by ViewModel

Description

As the former ViewPager, the newer ViewPager2 is generated from ViewGroup. There are few differences between them. Here's an image that depicts the ViewPager2: alt text

Advantages

  • Support RTL direction (Right to Left)
  • Support Adapter with RecyclerView
  • Support Orintation Horizontal/Veritcal
  • Support PageChangeCallback (More efficient code)
  • etc

Screenshot

alt text

References

  • https://developer.android.com/jetpack/androidx/releases/viewpager2
  • https://github.com/googlesamples/android-viewpager2
  • https://joebirch.co/2019/02/22/exploring-the-view-pager-2/?source=post_page---------------------------