Android ViewPager2 Scroll to Position

November 20, 2019
viewPager2.currentItem = 1

// if animation is required
viewPager2.setCurrentItem(1, true)

If it doesn’t work, you might need the following

viewPager.doOnLayout {
    viewPager.currentItem = 1
}

NOTE: doOnLayout from Android KTX

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.