How to change selected Tab Text color using TabLayout from code in Android?

It’s so simple using XML. Just add the following 2 attributes in your tab layout. app:tabSelectedTextColor=”@color/color_primary_text” app:tabTextColor=”@color/color_secondary_text” So, your code would look something like this. <android.support.design.widget.TabLayout android:id=”@+id/tab_layout” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:layout_alignParentBottom=”true” android:layout_alignParentStart=”true” android:layout_gravity=”bottom” android:background=”@color/button_background” android:fillViewport=”true” app:tabBackground=”@drawable/fixed_bottom_button” app:tabIndicatorColor=”@color/color_primary_text” app:tabMode=”fixed” app:tabSelectedTextColor=”@color/color_primary_text” app:tabTextColor=”@color/color_secondary_text” />

How do I change a tab background color when using TabLayout?

What finally worked for me is similar to what @如果我是DJ suggested, but the tabBackground should be in the layout file and not inside the style, so it looks like: res/layout/somefile.xml: <android.support.design.widget.TabLayout …. app:tabBackground=”@drawable/tab_color_selector” … /> and the selector res/drawable/tab_color_selector.xml: <?xml version=”1.0″ encoding=”utf-8″?> <selector xmlns:android=”http://schemas.android.com/apk/res/android”> <item android:drawable=”@color/tab_background_selected” android:state_selected=”true”/> <item android:drawable=”@color/tab_background_unselected”/> </selector>

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)