Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Change Text Color of tab Layout?

Tags:

I have this code for change color of text of tab layout, but it does not work at all!

app:tabTextColor does not work, and it cant change color to white.

    <android.support.design.widget.TabLayout         android:id="@+id/tabs"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:background="@color/white"         app:tabIndicatorColor="@color/blue"         app:tabIndicatorHeight="5dp"         app:tabTextColor="@color/white" /> 
like image 642
SadeQ digitALLife Avatar asked Dec 03 '17 07:12

SadeQ digitALLife


People also ask

How do I change the color of my tab text?

Right-click the worksheet tab whose color you want to change. Choose Tab Color, and then select the color you want. The color of the tab changes, but not the color of the font. When you choose a dark tab color, the font switches to white, and when you choose a light color for the tab, the font switches to black.


2 Answers

Try with it -

<android.support.design.widget.TabLayout         android:layout_width="match_parent"         android:layout_height="wrap_content"         app:tabMode="fixed"         app:tabGravity="fill"         android:background="@color/colorWhite"         app:tabTextColor="@color/colorBlack"         app:tabSelectedTextColor="@color/colorPrimary"/> 
like image 53
AGM Tazim Avatar answered Sep 28 '22 07:09

AGM Tazim


Use this code it would help in all api level api 18 to api 26

tabLayout.setupWithViewPager(viewPager,true);         tabLayout.setSelected(true);          tabLayout.setTabTextColors(getResources().getColor(R.color.colorHintTextLight),                   getResources().getColor(R.color.colorPrimaryTextLight));  <color name="colorHintTextLight">#80FFFFFF</color>     <color name="colorPrimaryTextLight">#FFFFFF</color> 

that would help u.it helps me when tab layout change the position.

like image 23
Mayank Garg Avatar answered Sep 28 '22 06:09

Mayank Garg