Tabs of TabLayout not showing

前端 未结 6 682
借酒劲吻你
借酒劲吻你 2020-12-30 08:19

I have a main activity, which hosts a fragment, which in turn hosts a TabLayout (with a ViewPager). The tab bar is shown, baut the tabs themselves are not shown.

Her

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-30 08:53

    Set tab icons after setupWithViewPager()

    private void setTabs {
       tabLayout.setupWithViewPager(viewPager);
       setupTabIcons();
    } 
    
    private void setupTabIcons() {
       tabLayout.getTabAt(0).setIcon(tabIcons[0]);
       tabLayout.getTabAt(1).setIcon(tabIcons[1]);
       tabLayout.getTabAt(2).setIcon(tabIcons[2]);
    }
    

提交回复
热议问题