0

Currently the selected tab in my app is highlighted in blue, like shown below.

How can I give it a different color?

app screenshot

Tomalak
  • 332,285
  • 67
  • 532
  • 628
aboseraj
  • 131
  • 1
  • 5

1 Answers1

1

You can do something like this :

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);
}

Check this answer https://stackoverflow.com/a/15750561/3651574. It will solve your problem. Cheers!!

Community
  • 1
  • 1
Fahid Nadeem
  • 412
  • 2
  • 7
  • 19