简体   繁体   中英

Custom TabLayout with different tabs width

Can anyone suggest how to implement a similar TabLayout ?

例

分页布局 .

I think I need to use the weight for the selected tab in the fixed mode.

you can use it . when you selecte item tab , you can change icon

tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
    @Override
    public void onTabSelected(TabLayout.Tab tab) {
        tab.setIcon(R.drawable.newicon);
         //also you can use tab.setCustomView() too
    }

    @Override
    public void onTabUnselected(TabLayout.Tab tab) {
        tab.setIcon(R.drawable.oldicon);
    }

    @Override
    public void onTabReselected(TabLayout.Tab tab) {

    }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM