0

I want to change font color of this tab activity:

enter image description here

using this style :

<style name="MyTheme" parent="MyTheme.Base"/>

<style name="MyTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="drawerArrowStyle">@style/IconStyle</item>
    <item name="android:actionBarTabTextStyle">@style/tabtextcolor</item>
</style>

<style name="IconStyle" parent="@style/Widget.AppCompat.DrawerArrowToggle">
    <item name="spinBars">true</item>
    <item name="color">@color/colorAccent</item>
</style>

<style name="tabtextcolor" parent="android:Widget.Holo.Light.ActionBar.TabText">
    <item name="android:textColor">@color/colorAccent</item>
</style>

but the tab text color still white. what did I miss here? thank you.

Saint Robson
  • 5,475
  • 18
  • 71
  • 118

2 Answers2

2

in your XML:

  <android.support.design.widget.TabLayout
    android:id="@+id/tabLayout"
    style="@style/AppTabLayout"   
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:background="@color/colorPrimary"
    app:tabTextAppearance="@style/AppTabTextAppearance" /> //custom style for tab text

Now in your

res/values/styles:

 <style name="AppTabLayout" parent="Widget.Design.TabLayout">
    <item name="tabIndicatorColor">@color/colorAccent</item>
    <item name="tabIndicatorHeight">4dp</item>
    <item name="tabPaddingStart">6dp</item>
    <item name="tabPaddingEnd">6dp</item>
    <item name="tabTextAppearance">@style/AppTabTextAppearance</item>
    <item name="tabSelectedTextColor">@color/color_white</item>  //selected color
</style>

<!-- for text -->
<style name="AppTabTextAppearance" parent="TextAppearance.Design.Tab">
    <item name="android:textSize">12sp</item>
    <item name="android:textColor">@color/color_black</item>   // default color
    <item name="textAllCaps">false</item>
</style>
rafsanahmad007
  • 23,683
  • 6
  • 47
  • 62
1

here is the simple solution for this. Remove that style from your theme.

 <android.support.design.widget.TabLayout
    ....
    app:tabTextColor="@color/your_color" />
Ankush Bist
  • 1,862
  • 1
  • 15
  • 32