Stepan Mazokha
Stepan Mazokha

Reputation: 457

How to change selected tab title color

I need to change selected tab color in my tab activity.

For example, selected item text color must be #cea939, and unselected items colors have to be #d7ba60. What should I do to change that? Actually, I tried to add textColor value to apptheme_tab_indicator.xml - but no result. By the way, I use AppCompat. And if there is a solution, how does it vary for styles and styles-v21?

Upvotes: 1

Views: 1387

Answers (1)

Xcihnegn
Xcihnegn

Reputation: 11597

You can check my answer for the post How to change Viewpager tab colour dynamically?, use custom view for tabs, and chage the codes of background color setting to text color setting:

Tab selectedTab = yourActionBar.getSelectedTab();
View tabView = selectedTab.getCustomView();
TextView text = (TextView)tabView.findViewById(R.id.your_text_id);  
text.setColor(your_text_color);

Hope this help!

Upvotes: 1

Related Questions