How to change color of Selected Tab
myTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener(){
@Override
public void onTabChanged(String tabId) {
int tab = myTabHost.getCurrentTab();
View view = myTabHost.getTabWidget().getChildAt(tab).setBackgroundColor(Color.CYAN);
}
});
I really recommend you to use the Actionbar Style Generator.
With that tool you can easily theme your graphic elements in your toolbar.
put this function and call it to yout Activity and pass tabhost as a parameter
public static void setTabColor(TabHost tabhost) {
for (int i = 0; i < tabhost.getTabWidget().getChildCount(); i++) {
tabhost.getTabWidget().getChildAt(i)
.setBackgroundResource(R.drawable.header_blank); // unselected
}
tabhost.getTabWidget().setCurrentTab(0);
tabhost.getTabWidget().getChildAt(tabhost.getCurrentTab())
.setBackgroundResource(R.drawable.tab_selected_new); // selected
// //have
// to
// change
}
call this as following way
setTabColor(tabHost);
tabHost.setOnTabChangedListener(new OnTabChangeListener() {
@Override
public void onTabChanged(String arg0) {
setTabColor(tabHost);
}
});
hope this is useful to you