Android滑动页面导航效果: PagerSlidingTabStrip

把github上的PagerSlidingTabStrip稍作修改:

tab的文字颜色选中变色(原版文字不变色)


栗子:http://download.csdn.net/detail/onlyonecoder/7722021


PagerSlidingTabStrip 自定义属性列表:

  • pstsIndicatorColor Color of the sliding indicator
  • pstsUnderlineColor Color of the full-width line on the bottom of the view
  • pstsDividerColor Color of the dividers between tabs
  • pstsIndicatorHeightHeight of the sliding indicator
  • pstsUnderlineHeight Height of the full-width line on the bottom of the view
  • pstsDividerPadding Top and bottom padding of the dividers
  • pstsTabPaddingLeftRight Left and right padding of each tab
  • pstsScrollOffset Scroll offset of the selected tab
  • pstsTabBackground Background drawable of each tab, should be a StateListDrawable
  • pstsShouldExpand If set to true, each tab is given the same weight, default false
  • pstsTextAllCaps If true, all tab titles will be upper case, default true
修改后加了一个属性 selectedTabTextColor

如果不设置 默认和 滑动指示器颜色(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>




Android滑动页面导航效果: PagerSlidingTabStrip,,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。