I have TabLayout setup with a ViewPager. When I select a tab the ViewPager scroll to the selected page with animation (showing all the pages in between current page and selected page). I want ViewPager to directly jump to the selected page.
I know I can use viewPager.setCurrentItem(1, false) to disable smoothScroll. But I want to change the default behavior to disable smoothScroll effect on ViewPager
Here is what I have done.
val mSectionsPagerAdapter = SectionsPagerAdapter(supportFragmentManager)
        vp!!.adapter = mSectionsPagerAdapter
        vp!!.addOnPageChangeListener(object: ViewPager.OnPageChangeListener {
            override fun onPageScrollStateChanged(state: Int) {
            }
            override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
            }
            override fun onPageSelected(position: Int) {
                when (position) {
                    0 -> supportActionBar!!.title = "Page 1"
                    1 -> supportActionBar!!.title = "Page 2"
                    2 -> supportActionBar!!.title = "Page 3"
                    3 -> supportActionBar!!.title = "Page 4"
                }
            }
        })
        tabLayout.setupWithViewPager(vp)