Android滑动页面导航效果: PagerSlidingTabStrip

把github上的PagerSlidingTabStrip稍作修改:

tab的文字颜色选中变色(原版文字不变色),类似微信导航


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


PagerSlidingTabStrip 自定义属性列表:

  • pstsUnderlineHeight Height of the full-width line on the bottom of the view
  • pstsTextAllCaps If true, all tab titles will be upper case, default true
  • 修改后加了一个属性 selectedTabTextColor

    如果不设置 默认和 滑动指示器颜色(pstsIndicatorColor)一致


    下图效果的代码:


    1. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
    2.     xmlns:tools="http://schemas.android.com/tools"  
    3.     android:layout_width="match_parent"  
    4.     android:layout_height="match_parent"   
    5.     xmlns:app="http://schemas.android.com/apk/res/org.lmw.demo.slidingtab">  
    6.   
    7.     <org.lmw.demo.slidingtab.widget.PagerSlidingTabStrip  
    8.         android:id="@+id/tabs"  
    9.         android:layout_width="match_parent"  
    10.         android:layout_height="40dp"  
    11.         app:pstsShouldExpand="true"  
    12.         app:pstsUnderlineHeight="2dp"  
    13.         app:pstsIndicatorHeight="2dp"  
    14.         app:pstsIndicatorColor="@android:color/holo_blue_light"  
    15.         app:selectedTabTextColor="@android:color/holo_blue_light"  
    16.         app:pstsDividerColor="@android:color/transparent"  
    17.         app:pstsTabBackground="@drawable/background_tab"  
    18.         android:background="@android:color/white"  
    19.          />  
    20.   
    21.     <android.support.v4.view.ViewPager  
    22.         android:id="@+id/pager"  
    23.         android:layout_width="match_parent"  
    24.         android:layout_height="wrap_content"  
    25.         android:layout_below="@+id/tabs" />  
    26.   
    27. </RelativeLayout>  



posted @ 2016-11-05 18:38  天涯海角路  阅读(237)  评论(0)    收藏  举报