@Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { int tabStripChildCount = mTabStrip.getChildCount(); if ((tabStripChildCount == 0) || (position < 0) || (position >= tabStripChildCount)) { return; } //添加的内容下 mTabStrip.onViewPagerPageChanged(position, positionOffset); TextView selectedTitle =(TextView) mTabStrip.getChildAt(position);//需改为TextView selectedTitle.setTextColor(Color.WHITE); for(int i = 0;i<tabStripChildCount;i++){ if(i==position){ continue; }else { TextView otherView =(TextView) mTabStrip.getChildAt(i); otherView.setTextColor(Color.BLACK); } } //添加的内容↑ int extraOffset = (selectedTitle != null) ? (int) (positionOffset * selectedTitle.getWidth()) : 0; scrollToTab(position, extraOffset); if (mViewPagerPageChangeListener != null) { mViewPagerPageChangeListener.onPageScrolled(position, positionOffset, positionOffsetPixels); } }在InternalViewPagerListener里添加上面的内容即可,同理可更改选中的大小等等。。。
SlidingTabLayout更改选中的选项卡文字颜色
最新推荐文章于 2022-08-14 08:46:21 发布