diff --git a/android/widgets/src/main/java/org/nativescript/widgets/TabLayout.java b/android/widgets/src/main/java/org/nativescript/widgets/TabLayout.java index 8cd42450c..5252540f6 100644 --- a/android/widgets/src/main/java/org/nativescript/widgets/TabLayout.java +++ b/android/widgets/src/main/java/org/nativescript/widgets/TabLayout.java @@ -131,19 +131,19 @@ public class TabLayout extends HorizontalScrollView { return this.mSelectedIndicatorColors; } - public void setTabTextColor(Integer color){ + public void setTabTextColor(int color){ mTabStrip.setTabTextColor(color); } - public Integer getTabTextColor(){ + public int getTabTextColor(){ return mTabStrip.getTabTextColor(); } - public void setSelectedTabTextColor(Integer color){ + public void setSelectedTabTextColor(int color){ mTabStrip.setSelectedTabTextColor(color); } - public Integer getSelectedTabTextColor(){ + public int getSelectedTabTextColor(){ return mTabStrip.getSelectedTabTextColor(); } diff --git a/android/widgets/src/main/java/org/nativescript/widgets/TabStrip.java b/android/widgets/src/main/java/org/nativescript/widgets/TabStrip.java index 48c7b2202..b30fe443a 100644 --- a/android/widgets/src/main/java/org/nativescript/widgets/TabStrip.java +++ b/android/widgets/src/main/java/org/nativescript/widgets/TabStrip.java @@ -50,9 +50,8 @@ class TabStrip extends LinearLayout { private TabLayout.TabColorizer mCustomTabColorizer; private final SimpleTabColorizer mDefaultTabColorizer; - private int mDefaultTabTextColor; - private int mTabTextColor = -1; - private int mSelectedTabTextColor = -1; + private int mTabTextColor; + private int mSelectedTabTextColor; TabStrip(Context context) { this(context, null); @@ -83,7 +82,10 @@ class TabStrip extends LinearLayout { mSelectedIndicatorPaint = new Paint(); 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) { @@ -122,20 +124,10 @@ class TabStrip extends LinearLayout { LinearLayout linearLayout = (LinearLayout)getChildAt(i); TextView textView = (TextView)linearLayout.getChildAt(1); if (i == mSelectedPosition){ - if (mSelectedTabTextColor >= 0){ - textView.setTextColor(mSelectedTabTextColor); - } - else { - textView.setTextColor(mDefaultTabTextColor); - } + textView.setTextColor(mSelectedTabTextColor); } else { - if (mTabTextColor >= 0){ - textView.setTextColor(mTabTextColor); - } - else { - textView.setTextColor(mDefaultTabTextColor); - } + textView.setTextColor(mTabTextColor); } } }