如何使用选择器通过新的TabLayout更改图标 [英] How to use selectors to change icons with the new TabLayout

查看:83
本文介绍了如何使用选择器通过新的TabLayout更改图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Android的新支持TabLayout.事情是,我想使用选择当选择一个标签更改图标.

I'm using the new support TabLayout from Android. The thing is that I wanted to use selectors to change the icon when a tab is selected.

我一直在研究源代码,在我看来,它永远不会改变视图的状态(因此,我不能使用选择器).

I've been looking into the source code and it seems to me that the it never changes the state of the view (and for that reason I can't use the selector).

有人知道一些解决方法吗?

Does anyone knows some workaround?

谢谢!

推荐答案

可以通过

There is way to set customView as a tab with setCustomView(View view) method. So you can create a textview and set a selector to it and set this view to tab.

希望它对您有帮助!

这篇关于如何使用选择器通过新的TabLayout更改图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆