Open abc2005 opened 10 years ago
me too
tabs.setBackgroundColor(Color.BLACK);
If you want to keep the bottom indicator, you define the main color of the tab directly in the layout, like in this example: <com.astuetz.PagerSlidingTabStrip android:id="@+id/tabs" android:layout_width="match_parent" android:layout_height="48dip" app:pstsShouldExpand="true" app:pstsIndicatorColor="@color/turquoise" android:background="@android:color/white" />
So my main color is white and the indicator color is turqoise. If you want to change the DrawableStateList for pressed and focused states, always keep transparent as the default color, and pick any color for your desired states.
Thanks vandus ! I confirm: "...always keep transparent as the default color, and pick any color for your desired states."
in order to keep the indicator, you should set the code like below
PagerSlidingTabStrip:pstsTabBackground="@drawable/tab_bg_selector"
android:background="@color/fancy_white"
the selector is
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@color/theme_color"/>
<item android:state_selected="true" android:drawable="@color/theme_color"/>
<item android:drawable="@color/transparent"/>
</selector>
delete the pstsUnderlineColor
attr if you have set, otherwise the indicator won`t shown.
HI thanks you for this perfect tab. I just wanted to know how can I change tab background color ? I tried to change it from xml but it didn't work . Could you help me ?
thanks you