How to scroll tablayout programmatically - Android

前端 未结 13 2351
终归单人心
终归单人心 2021-02-07 00:31

I have created 30 scrollable tabs using tablayout.

So first three tabs are visible on screen and rest of them are invisible which can be scroll using swipe gesture.

13条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-07 00:46

    tab = tabLayout.getSelectedTabPosition();
                tab++;
                TabLayout.Tab tabs = tabLayout.getTabAt(tab);
                if (tabs != null) {
                    tabs.select();
                }
                else {
                    tabLayout.getTabAt(0).select();
                }
    

    if you want next tab on click event then use this code its work perfactly

提交回复
热议问题