How to set unselected text color for TabLayout.Tab - Android

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

+7
source share
2 answers

Use the app:tabTextColordefault tab color and the app:tabSelectedTextColorselected tab color.

        <android.support.design.widget.TabLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabTextColor="#000000"
            app:tabSelectedTextColor="#FFFFFF"/>
+15
source

You can use style:

Add to 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"
 />
0
source

Source: https://habr.com/ru/post/1665155/


All Articles