1. Modify the background color in the Pagertabstrip
We can set the background property directly in the layout:
<Android.support.v4.view.ViewPager Android:id= "@+id/Pager Android:layout_width="Fill_parent" android:layout_height="Fill_parent" > <Android.support.v4.view.PagerTabStrip android:id= "@+id/pts" android:layout_width="wrap_content " android:layout_height="50DP" android:layout_gravity="Top " android:background="#a05c5ccc"/> </android.support.v4.view.viewpager>
2. Modify the color of the indicator bar
We can call it in Java code.
Pagertabstrip Settabindicatorcolorresource (R.color.green_complete); method to set
3. To modify the color of the set header font, and to add an icon for the caption, we can rewrite the Fragmentstatepageradapter Getpagetitle method:
@Override Public Charsequence Getpagetitle (int POS) { Spannablestringbuilder SSB =New Spannablestringbuilder (" " + Topics[pos]);Space added before text for drawable mydrawable = Context.getresources (). Getdrawable ( R.drawable.card_visited_like); Mydrawable.setbounds (0,0, Mydrawable.getintrinsicwidth (), Mydrawable.getintrinsicheight ()); Imagespan span =New Imagespan (mydrawable, imagespan.align_baseline); Foregroundcolorspan FCS = New Foregroundcolorspan (Color.green); //font color set to green Ssb.setspan (span, 0, 1, spannable.span_exclusive_exclusive); //set icon Ssb.setspan (FCS, 1, Ssb.length (), spannable.span_exclusive_exclusive); //set font color Ssb.setspan (new Relativesizespan (1.2f), 1, Ssb.length (), spannable.span_exclusive_ EXCLUSIVE); return ssb;}
Effects such as:
Android: Modify the background color in the Pagertabstrip, the style of the title font, the color and icon, and the color of the indicator bar