1、ViewPagerIndicator使用:http://www.jianshu.com/p/a2263ee3e7c3
2、 ViewPagerIndicator使用:--TabPageIndicator浅析:
http://hexo.trity.cc/2015/04/14/Android-ViewPagerIndicator-TabPageIndicator/
此处在设置
TabPageIndicator的主题样式(下划线、点击的样式等)时需要注意,样式必须设置在Activity的Theme,如下例所示:
<!-- 第一步设置主题 -->
<style name="StyledIndicators" parent="@android:style/Theme.Light">
<item name="vpiTabPageIndicatorStyle">@style/CustomTabPageIndicator</item>
</style>
<!-- 第二步设置主题 -->
<style name="CustomTabPageIndicator" parent="Widget.TabPageIndicator">
<!-- 点击时在不同状态下显示的背景色 -->
<item name="android:background">@drawable/custom_tab_indicator</item>
<!-- 分割线图片设置 -->
<item name="android:divider">@drawable/custom_tab_indicator_divider</item>
<!-- 设置分割线的显示位置,或是不显示 -->
<item name="android:showDividers">none</item>
<item name="android:textAppearance">@style/CustomTabPageIndicator.Text</item>
<item name="android:textColor">#FF555555</item>
<item name="android:textSize">16sp</item>
<item name="android:dividerPadding">10dp</item>
<item name="android:paddingLeft">8dp</item>
<item name="android:paddingRight">8dp</item>
<item name="android:fadingEdgeLength">10dp</item>
<item name="android:fadingEdge">horizontal</item>
</style>
<!-- 第三步设置主题 -->
<style name="CustomTabPageIndicator.Text" parent="android:TextAppearance.Medium">
<item name="android:typeface">monospace</item>
</style>
<activity
android:name=".SampleTabsStyled"
android:label="Tabs/Styled"
android:theme="@style/StyledIndicators" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="com.jakewharton.android.viewpagerindicator.sample.SAMPLE" />
</intent-filter>
</activity>
3、github: https://github.com/JakeWharton/ViewPagerIndicator
4、解决ViewPagerIndicator标题显示不全的问题
修改源码中的TabPageIndicator.Java,将默认的注释掉,换为如下代码即可:
//mTabLayout.addView(tabView, new LinearLayout.LayoutParams(0, MATCH_PARENT, 1));
mTabLayout.addView(tabView, new LinearLayout.LayoutParams(WRAP_CONTENT, MATCH_PARENT, 1));