Skip to content

Commit 63302a4

Browse files
author
Alexander Vakrilov
authored
Merge pull request #84 from NativeScript/colors
TabView colors fixes
2 parents 8b528f0 + 6ee120b commit 63302a4

File tree

2 files changed

+12
-20
lines changed

2 files changed

+12
-20
lines changed

android/widgets/src/main/java/org/nativescript/widgets/TabLayout.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,19 +131,19 @@ public int[] getSelectedIndicatorColors() {
131131
return this.mSelectedIndicatorColors;
132132
}
133133

134-
public void setTabTextColor(Integer color){
134+
public void setTabTextColor(int color){
135135
mTabStrip.setTabTextColor(color);
136136
}
137137

138-
public Integer getTabTextColor(){
138+
public int getTabTextColor(){
139139
return mTabStrip.getTabTextColor();
140140
}
141141

142-
public void setSelectedTabTextColor(Integer color){
142+
public void setSelectedTabTextColor(int color){
143143
mTabStrip.setSelectedTabTextColor(color);
144144
}
145145

146-
public Integer getSelectedTabTextColor(){
146+
public int getSelectedTabTextColor(){
147147
return mTabStrip.getSelectedTabTextColor();
148148
}
149149

android/widgets/src/main/java/org/nativescript/widgets/TabStrip.java

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,8 @@ class TabStrip extends LinearLayout {
5050
private TabLayout.TabColorizer mCustomTabColorizer;
5151
private final SimpleTabColorizer mDefaultTabColorizer;
5252

53-
private int mDefaultTabTextColor;
54-
private int mTabTextColor = -1;
55-
private int mSelectedTabTextColor = -1;
53+
private int mTabTextColor;
54+
private int mSelectedTabTextColor;
5655

5756
TabStrip(Context context) {
5857
this(context, null);
@@ -83,7 +82,10 @@ class TabStrip extends LinearLayout {
8382
mSelectedIndicatorPaint = new Paint();
8483

8584
TextView defaultTextView = new TextView(context);
86-
mDefaultTabTextColor = defaultTextView.getTextColors().getDefaultColor();
85+
mTabTextColor = defaultTextView.getTextColors().getDefaultColor();
86+
87+
// Default selected color is the same as mTabTextColor
88+
mSelectedTabTextColor = mTabTextColor;
8789
}
8890

8991
void setCustomTabColorizer(TabLayout.TabColorizer customTabColorizer) {
@@ -122,20 +124,10 @@ private void updateTabsTextColor(){
122124
LinearLayout linearLayout = (LinearLayout)getChildAt(i);
123125
TextView textView = (TextView)linearLayout.getChildAt(1);
124126
if (i == mSelectedPosition){
125-
if (mSelectedTabTextColor >= 0){
126-
textView.setTextColor(mSelectedTabTextColor);
127-
}
128-
else {
129-
textView.setTextColor(mDefaultTabTextColor);
130-
}
127+
textView.setTextColor(mSelectedTabTextColor);
131128
}
132129
else {
133-
if (mTabTextColor >= 0){
134-
textView.setTextColor(mTabTextColor);
135-
}
136-
else {
137-
textView.setTextColor(mDefaultTabTextColor);
138-
}
130+
textView.setTextColor(mTabTextColor);
139131
}
140132
}
141133
}

0 commit comments

Comments
 (0)