![](/img/trans.png)
[英]Why does BottomNavigationView not changing selected tab Icon?
[英]Changing the icon of selected tab
我按如下方式设置tablayout,
private void setupTabIcons() {
TextView tabOne = (TextView) LayoutInflater.from(this).inflate(R.layout.custom_tab, null);
tabOne.setText("Status");
tabOne.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.status, 0, 0);
tabLayout.getTabAt(0).setCustomView(tabOne);
TextView tabTwo = (TextView) LayoutInflater.from(this).inflate(R.layout.custom_tab, null);
tabTwo.setText("Rating");
tabTwo.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.rateit, 0, 0);
tabLayout.getTabAt(1).setCustomView(tabTwo);
}
如何更改所选标签的图标? 即时通讯使用tablayout。
我正在使用TabLayout.OnTabSelectedListener
:
wptabs.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) {
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.