What is the difference between tabLayout.setScrollPosition(int, float, boolean);
and tabLayout.getTabAt(int);
methods?
because, I can also set the tabLayout
to indicate to the next by using setScrollPosition
, but, the problem with this approach is that this Method does not update the Integer returned by tabLayout.getSelectedTabPosition();
getTabAt : Returns the tab at the specified index.(TabLayout.Tab)
getSelectedTabPosition: Returns the position of the current selected tab. -selected tab position, or -1 if there isn't a selected tab.-
setScrollPosition :
void setScrollPosition (int position,
float positionOffset,
boolean updateSelectedText)
Set the scroll position of the tabs. This is useful for when the tabs are being displayed as part of a scrolling container such as ViewPager.
Calling this method does not update the selected tab, it is only used for drawing purposes.
position -> int: current scroll position
positionOffset -> float: Value from [0, 1) indicating the offset from position.
positionOffset -> boolean: Whether to update the text's selected state.