You can set the Listener for TabHost with setOnTabChangedListener and change it dynamically,
public void onCreate(Bundle savedInstanceState){
Create a method that sets the color of the Selected and Unselected Tab .
private void setSelectedTabColor() { for(int i=0;i<tabHost.getTabWidget().getChildCount();i++) { tabHost.getTabWidget().getChildAt(i) .setBackgroundColor(Color.WHITE); } tabHost.getTabWidget().getChildAt(tabHost.getCurrentTab()) .setBackgroundColor(Color.RED); }
Then inside your onTabChanged() you can dynamically change the background.
@Override public void onTabChanged(String tabId) { setSelectedTabColor(); }
You can use the same for the Selected and Unselected Tab, here for the same blog.
Lalit poptani
source share