Posts

Posts uit april, 2020 tonen

ViewPager2

Afbeelding
At the Google I/O 2019 ViewPager2 was announced, a large step forward compared the the good old ViewPager. This tutorial goes about ViewPager2, so we are going to skip an introduction about ViewPager and in which use cases you should use it!. ViewPager2 is part of the AndroidX JetPack library, more information about AndroidX can in this tutorial. Why use a ViewPager2? When we want to manage multiple screens through swiping for example within TabLayout or to navigate from item A to item B. One of the biggest benefits of the ViewPager2 is that it uses the RecyclerView, one of the most used layouts in Android. By using the RecyclerView we get for support for or right-to-left (RTL), improved performing, support of DiffUtil. Within ViewPager2 you are no longer forced to use Fragments, There is still an option to use fragments with the FragmentStateAdapter but we won't dive into that part. We are focussing on a ViewPa