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:
@Overridepublic charsequence getpagetitle (int pos) {Spannablestringbuilder SSB = new Spannablestringbuilder ("" + topics[ POS]); Space added before text fordrawable 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:
Project Source code: Https://github.com/nuptboyzhb/ViewPageAnimatorDemo
Not permitted for commercial purposes without permission