Sync Tab Layout Indicator with Recycler View Scroll

Viewed 327

I have recyclerview synced with the material tab layout. When I scroll to the bottom, tab changes. But the problem is I am changing the tab using the following function. I need to animate the indicator according to the scroll position. For example, if I see my recyclerview item's %80 percent the indicator needs to scroll %80 percent.

    fun selectTab(position: Int) {
        val tab = tabLayout.getTabAt(position)
        tab?.select()
    }

The following functions don't change the position of the indicator.

scrollTo(x, y)
smoothScrollTo(x, y)
0 Answers
Related