Hear I found Jake Wharton blog which includes some changes in Viewpager indicator styles
我希望在选择标签文字大于默认和粗体
时进行更改使用此main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<com.viewpagerindicator.TabPageIndicator
android:id="@+id/indicator"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="5dp"
android:layout_weight="1" />
</LinearLayout>
和
style.xml
<style name="Theme.VPI" parent="Theme.Styled">
<item name="vpiTabPageIndicatorStyle">@style/CustomTabPageIndicator</item>
</style>
<!-- "Implementation" of our ABS custom theme -->
<style name="Widget.Styled.ActionBar" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">
<item name="titleTextStyle">@style/TitleText</item>
<item name="android:titleTextStyle">@style/TitleText</item>
</style>
<!-- "Implementation" of VPI theme. We just set the text size and color.TabPageIndicator -->
<style name="CustomTabPageIndicator" parent="Widget.TabPageIndicator">
<item name="android:textStyle">@style/CustomTabPageIndicator.Text</item>
<item name="android:background">@drawable/tab_indicator</item>
<item name="android:animateOnClick">true</item>
</style>
<style name="CustomTabPageIndicator.Text" parent="android:TextAppearance.Medium">
<item name="android:textColor">@drawable/tab_text_style</item>
<item name="android:textSize">18sp</item>
<item name="android:textStyle">@style/TitleText</item>
</style>
<!-- More customizations for ABS <item name="android:textStyle">bold</item> -->
<style name="TitleText" parent="Widget.TabPageIndicator.Text">
<item name="android:textColor">@color/white</item>
<item name="android:textSize">20sp</item>
<item name="android:textStyle">bold</item>
<item name="android:ellipsize">end</item>
<item name="android:singleLine">true</item>
</style>
和drawbale tab_text_style.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_selected="true"
android:color="@color/tab_text_selected" />
<item
android:state_selected="false"
android:color="@color/tab_text_unselected" />
</selector>
我的标签看起来像这样,我正在使用ViewPagerIndicator与ActionBarSherlock
我希望看起来像这样......
提前致谢