From 545ce4665c1d506393908b55aafd681a45c774e6 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期五, 02 四月 2021 19:14:22 +0800 Subject: [PATCH] 3.9.0bug优化 --- library-ViewPagerIndicator/src/com/viewpagerindicator/MainTabPageIndicator.java | 19 +++++++++++++++++-- 1 files changed, 17 insertions(+), 2 deletions(-) diff --git a/library-ViewPagerIndicator/src/com/viewpagerindicator/MainTabPageIndicator.java b/library-ViewPagerIndicator/src/com/viewpagerindicator/MainTabPageIndicator.java index 6ca7bbe..53e0876 100644 --- a/library-ViewPagerIndicator/src/com/viewpagerindicator/MainTabPageIndicator.java +++ b/library-ViewPagerIndicator/src/com/viewpagerindicator/MainTabPageIndicator.java @@ -88,6 +88,9 @@ private int textColor; private int highLightTextColor; + private int textSpecialColorPosition = -1; + private int textSpecialColor; + private OnTabReselectedListener mTabReselectedListener; public MainTabPageIndicator(Context context) { @@ -97,6 +100,11 @@ public void setTextColor(int textColor, int highLightTextColor) { this.textColor = textColor; this.highLightTextColor = highLightTextColor; + } + + public void setTextSpecialColor(int position, int color) { + this.textSpecialColorPosition = position; + this.textSpecialColor = color; } @@ -155,7 +163,11 @@ } for (int i = 0; i < mTabLayout.getChildCount(); i++) { ((TextView) mTabLayout.getChildAt(i)).setTextSize(15); - ((TextView) mTabLayout.getChildAt(i)).setTextColor(textColor); + if (i == textSpecialColorPosition) { + ((TextView) mTabLayout.getChildAt(i)).setTextColor(textSpecialColor); + } else { + ((TextView) mTabLayout.getChildAt(i)).setTextColor(textColor); + } ((TextView) mTabLayout.getChildAt(i)).setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL)); } ((TextView) tabView).setTextColor(highLightTextColor); @@ -208,7 +220,10 @@ tabView.setOnClickListener(mTabClickListener); tabView.setText(text); if (textColor > 0) { - tabView.setTextColor(textColor); + if (index == textSpecialColorPosition) { + tabView.setTextColor(textSpecialColor); + } else + tabView.setTextColor(textColor); } else { tabView.setTextColor(R.color.black1); } -- Gitblit v1.8.0