colors api changed

This commit is contained in:
vakrilov
2017-02-14 07:09:25 +02:00
parent 8b528f0427
commit 6ee120ba28
2 changed files with 12 additions and 20 deletions

View File

@@ -131,19 +131,19 @@ public class TabLayout extends HorizontalScrollView {
return this.mSelectedIndicatorColors; return this.mSelectedIndicatorColors;
} }
public void setTabTextColor(Integer color){ public void setTabTextColor(int color){
mTabStrip.setTabTextColor(color); mTabStrip.setTabTextColor(color);
} }
public Integer getTabTextColor(){ public int getTabTextColor(){
return mTabStrip.getTabTextColor(); return mTabStrip.getTabTextColor();
} }
public void setSelectedTabTextColor(Integer color){ public void setSelectedTabTextColor(int color){
mTabStrip.setSelectedTabTextColor(color); mTabStrip.setSelectedTabTextColor(color);
} }
public Integer getSelectedTabTextColor(){ public int getSelectedTabTextColor(){
return mTabStrip.getSelectedTabTextColor(); return mTabStrip.getSelectedTabTextColor();
} }

View File

@@ -50,9 +50,8 @@ class TabStrip extends LinearLayout {
private TabLayout.TabColorizer mCustomTabColorizer; private TabLayout.TabColorizer mCustomTabColorizer;
private final SimpleTabColorizer mDefaultTabColorizer; private final SimpleTabColorizer mDefaultTabColorizer;
private int mDefaultTabTextColor; private int mTabTextColor;
private int mTabTextColor = -1; private int mSelectedTabTextColor;
private int mSelectedTabTextColor = -1;
TabStrip(Context context) { TabStrip(Context context) {
this(context, null); this(context, null);
@@ -83,7 +82,10 @@ class TabStrip extends LinearLayout {
mSelectedIndicatorPaint = new Paint(); mSelectedIndicatorPaint = new Paint();
TextView defaultTextView = new TextView(context); TextView defaultTextView = new TextView(context);
mDefaultTabTextColor = defaultTextView.getTextColors().getDefaultColor(); mTabTextColor = defaultTextView.getTextColors().getDefaultColor();
// Default selected color is the same as mTabTextColor
mSelectedTabTextColor = mTabTextColor;
} }
void setCustomTabColorizer(TabLayout.TabColorizer customTabColorizer) { void setCustomTabColorizer(TabLayout.TabColorizer customTabColorizer) {
@@ -122,21 +124,11 @@ class TabStrip extends LinearLayout {
LinearLayout linearLayout = (LinearLayout)getChildAt(i); LinearLayout linearLayout = (LinearLayout)getChildAt(i);
TextView textView = (TextView)linearLayout.getChildAt(1); TextView textView = (TextView)linearLayout.getChildAt(1);
if (i == mSelectedPosition){ if (i == mSelectedPosition){
if (mSelectedTabTextColor >= 0){
textView.setTextColor(mSelectedTabTextColor); textView.setTextColor(mSelectedTabTextColor);
} }
else { else {
textView.setTextColor(mDefaultTabTextColor);
}
}
else {
if (mTabTextColor >= 0){
textView.setTextColor(mTabTextColor); textView.setTextColor(mTabTextColor);
} }
else {
textView.setTextColor(mDefaultTabTextColor);
}
}
} }
} }