If you look at TabLayout.class , you will see the internal TabView.class for the actual tab layout. The same layout as any other with the isSelected attribute. Selecting a tab will also affect this, so all you have to do is create a background selection for the selection, for example
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_selected="true" android:drawable="@color/tab_bg_selected"/> <item android:drawable="@color/tab_bg_unselected"/></selector>
and attach it to the tabBackground attribute, for example. in XML like
<android.support.design.widget.TabLayout android:layout_width="match_parent" android:layout_height="wrap_content" app:tabBackground="@drawable/tab_bg" app:tabIndicatorHeight="4dp"/>
Michal Sep 03 '15 at 11:48 2015-09-03 11:48
source share