Reputation: 197
TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
tabLayout.addTab(tabLayout.newTab().setText("Videos"));
tabLayout.addTab(tabLayout.newTab().setText("Games"));
tabLayout.addTab(tabLayout.newTab().setText("Music"));
Videos,games and music is coming in white.
With my current theme, it's coming (text in tab bar)white in color.I want to retain my theme and just want to change the color of text from white to any other color.
Upvotes: 0
Views: 140
Reputation: 2604
Try this
TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
tabLayout.addTab(tabLayout.newTab().setText("Videos"));
tabLayout.addTab(tabLayout.newTab().setText("Games"));
tabLayout.addTab(tabLayout.newTab().setText("Music"));
tabLayout.setTabTextColors(Color.parseColor("#ffffff"), Color.parseColor("#000000"));
Upvotes: 2
Reputation: 353
<style name="MyCustomTabLayout" parent="Widget.Design.TabLayout">
<item name="tabTextAppearance">@style/MyCustomTabText</item>
<item name="tabSelectedTextColor">@color/tab_text_act</item>
</style>
<style name="MyCustomTabText" parent="TextAppearance.AppCompat.Button">
<item name="android:textSize">14sp</item>
<item name="android:textColor">@color/tab_text</item>
</style>
This should allow you to change the color of the text to whatever you want
Upvotes: 0