PagerSlidingTabStrip 选中颜色

1.在attrs中,添加属性pstsSelectedTabTextColor

      
      
      
          
           
          
      
      

2.在构造函数中添加

selectedTabTextColor =a.getColor(R.styleable.PagerSlidingTabStrip_pstsSelectedTabTextColor, indicatorColor);

3.updateTabStyles中设置选中颜色

if (i == selectedPosition) {
tab.setTextColor(selectedTabTextColor);
}

4.PageListener的onPageSelected中监听点击事件

	private class MyPageChangeListener implements ViewPager.OnPageChangeListener {

		@Override
		public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

		}

		@Override
		public void onPageSelected(int position) {

			mTabPageIndicator.selectedPosition = position;
			mTabPageIndicator.updateTabStyles();
		}

		@Override
		public void onPageScrollStateChanged(int state) {

		}
	}


你可能感兴趣的:(PagerSlidingTabStrip 选中颜色)