简体   繁体   English

SlidingTabLayout按下时更改选项卡的背景色

[英]SlidingTabLayout change background colour of tab when pressed

I have created tabs for my application using this tutorial: http://www.android4devs.com/2015/01/how-to-make-material-design-sliding-tabs.html 我已使用此教程为我的应用创建了标签: http : //www.android4devs.com/2015/01/how-to-make-material-design-sliding-tabs.html

I have done this successfully and now trying to change the colour of the tab when pressed. 我已成功完成此操作,现在尝试按时更改选项卡的颜色。 It seems to have a built in default colour and I have googled quite alot but found no answers. 它似乎具有内置的默认颜色,我在Google上搜索了很多,但没有找到答案。

I have found how to change the background colour of the actual tab but I need to change the background when pressed. 我已经找到了如何更改实际选项卡的背景颜色,但是按下时需要更改背景。 Please can someone help me with this? 请有人可以帮我吗?

Note: this changed the background colour of the tab in normal state by adding it to the constructor of SlidingTabLayout 注意:通过将选项卡的背景色添加到SlidingTabLayout的构造函数中,可以更改其在正常状态下的背景色

this.setBackgroundColor(context.getResources().getColor(R.color.ColorPrimaryDark));

Thanks, Sam 谢谢山姆

Check here 在这里检查

But it suggest to use SmartTabLayout library which is better. 但是它建议使用更好的SmartTabLayout库

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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