如何更改滑动选项卡中选定的选项卡颜色?

问题描述:

目前我的应用程序中选定的选项卡以蓝色突出显示,如下所示。如何更改滑动选项卡中选定的选项卡颜色?

我怎样才能给它一种不同的颜色?

app screenshot

+0

将图像集成到问题中并相应地重新编写 – Tomalak 2015-04-02 09:14:07

你可以做这样的事情:

TabHost host = (TabHost)view.findViewById(R.id.tab_host); 
TabWidget widget = host.getTabWidget(); 
for(int i = 0; i < widget.getChildCount(); i++) { 
View v = widget.getChildAt(i); 

// Look for the title view to ensure this is an indicator and not a divider. 
TextView tv = (TextView)v.findViewById(android.R.id.title); 
if(tv == null) { 
    continue; 
} 
v.setBackgroundResource(R.drawable.your_tab_selector_drawable); 
} 

检查这个答案https://*.com/a/15750561/3651574。 它会解决你的问题。干杯!!