把github上的PagerSlidingTabStrip稍作修改:
tab的文字颜色选中变色(原版文字不变色),类似微信导航
栗子:http://download.youkuaiyun.com/detail/onlyonecoder/7722021
PagerSlidingTabStrip 自定义属性列表:
pstsIndicatorColorColor of the sliding indicatorpstsUnderlineColorColor of the full-width line on the bottom of the viewpstsDividerColorColor of the dividers between tabspstsIndicatorHeightHeight of the sliding indicatorpstsUnderlineHeightHeight of the full-width line on the bottom of the viewpstsDividerPaddingTop and bottom padding of the dividerspstsTabPaddingLeftRightLeft and right padding of each tabpstsScrollOffsetScroll offset of the selected tabpstsTabBackgroundBackground drawable of each tab, should be a StateListDrawablepstsShouldExpandIf set to true, each tab is given the same weight, default falsepstsTextAllCapsIf true, all tab titles will be upper case, default true
如果不设置 默认和 滑动指示器颜色(pstsIndicatorColor)一致
下图效果的代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res/org.lmw.demo.slidingtab">
<org.lmw.demo.slidingtab.widget.PagerSlidingTabStrip
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="40dp"
app:pstsShouldExpand="true"
app:pstsUnderlineHeight="2dp"
app:pstsIndicatorHeight="2dp"
app:pstsIndicatorColor="@android:color/holo_blue_light"
app:selectedTabTextColor="@android:color/holo_blue_light"
app:pstsDividerColor="@android:color/transparent"
app:pstsTabBackground="@drawable/background_tab"
android:background="@android:color/white"
/>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tabs" />
</RelativeLayout>
本文介绍了如何在PagerSlidingTabStrip基础上进行自定义,实现tab文字选中时颜色变化的功能,类似于微信导航栏的效果,并提供了代码示例。
215

被折叠的 条评论
为什么被折叠?



