How to set unselected Text Color for TabLayout.Tab - Android
Asked Answered
B

2

15

How do you set text-color for a tab that's not selected? I know you can set the text-color for the TabLayout by doing: setTabTextColors

Bathos answered 28/12, 2016 at 18:42 Comment(1)
Why don't you give default color to text and change it on selection?Westnorthwest
N
29

Use app:tabTextColor for default tab color and app:tabSelectedTextColor for selected tab color.

        <android.support.design.widget.TabLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabTextColor="#000000"
            app:tabSelectedTextColor="#FFFFFF"/>
Nazi answered 28/12, 2016 at 19:1 Comment(0)
U
0

You can use style:

Add in styles.xml:

<style name="CustomTabLayout" parent="Widget.Design.TabLayout">
     <item name="tabTextColor">@color/default_text_color</item>
</style>

use in xml

<android.support.design.widget.TabLayout 
    style="@style/CustomTabLayout"
 />
Unify answered 1/5, 2019 at 15:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.