Swipe views let you navigate between sibling screens, such as tabs, with a horizontal finger gesture, or swipe. This navigation pattern is also referred to as horizontal paging.
OneViewPager
You can use BaseViewPagerAdapter to create a viewpager for your application. In this OneViewPager, you don't need to create a separate class to create a page swipe, you only need to create a lazy variable.
Example:
Create an activity/fragment, then use TabLayout and ViewPager2 inside the activity/fragment.
private val viewPager by lazy {
object : BaseViewPagerAdapter<BaseFragment<*>>(this){
override fun createFragment(position: Int): Fragment =
getItem(position).fallback(Fragment())
}
}
Then, define the TabLayout, ViewPager and you can insert title and the Fragments. For example: