TabLayout中tab.setCustomView的操作

来源:互联网 发布:淘宝上拍卖的房子 编辑:程序博客网 时间:2024/06/06 03:25

tab的视图一旦被创建,我们不能再次在监听器中setCustomView(),这是无效的。 我们可以通过获取当前tab的视图,进行改变。

比如改变图片:

TabLayout.Tab tab = mTabLayout.getTabAt(position);View view = tab.getCustomView();ImageView imageView = (ImageView) view.findViewById(R.id.fragment_tab_layout_image_view);                    imageView.setImageDrawable(getResources().getDrawable(R.drawable.actionbar_discover_selected));


0 0
原创粉丝点击