From fd238846980b17d893d703ac8e56869bd3f23c89 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期三, 30 十一月 2022 23:10:13 +0800 Subject: [PATCH] 哀悼模式 --- library-ViewPagerIndicator/src/com/viewpagerindicator/MainTabPageIndicator.java | 29 ++++++++++++++++++++--------- 1 files changed, 20 insertions(+), 9 deletions(-) diff --git a/library-ViewPagerIndicator/src/com/viewpagerindicator/MainTabPageIndicator.java b/library-ViewPagerIndicator/src/com/viewpagerindicator/MainTabPageIndicator.java index 6ca7bbe..d34d160 100644 --- a/library-ViewPagerIndicator/src/com/viewpagerindicator/MainTabPageIndicator.java +++ b/library-ViewPagerIndicator/src/com/viewpagerindicator/MainTabPageIndicator.java @@ -21,16 +21,12 @@ import android.annotation.SuppressLint; import android.content.Context; -import android.content.res.Resources; import android.graphics.Color; import android.graphics.Typeface; -import android.support.v4.view.PagerAdapter; -import android.support.v4.view.ViewPager; -import android.support.v4.view.ViewPager.OnPageChangeListener; +import androidx.viewpager.widget.PagerAdapter; +import androidx.viewpager.widget.ViewPager; +import androidx.viewpager.widget.ViewPager.OnPageChangeListener; import android.util.AttributeSet; -import android.util.Log; -import android.util.TypedValue; -import android.view.Gravity; import android.view.View; import android.view.ViewGroup; import android.widget.HorizontalScrollView; @@ -88,6 +84,9 @@ private int textColor; private int highLightTextColor; + private int textSpecialColorPosition = -1; + private int textSpecialColor; + private OnTabReselectedListener mTabReselectedListener; public MainTabPageIndicator(Context context) { @@ -97,6 +96,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 +159,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 +216,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