From af3226da03cb84d6ad49299e07f50fc5ab533ebf Mon Sep 17 00:00:00 2001 From: Aurelien Hubert Date: Wed, 18 May 2016 14:48:14 +0200 Subject: Fixed bug when switching between normal and colored mode --- .../aurelhubert/ahbottomnavigation/AHBottomNavigation.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigation.java b/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigation.java index 8cbf821..238ab0f 100644 --- a/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigation.java +++ b/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigation.java @@ -74,6 +74,7 @@ public class AHBottomNavigation extends FrameLayout { //private int accentColor = Color.WHITE; //private int inactiveColor = Color.WHITE; private @ColorInt int itemActiveColor, itemInactiveColor; + private @ColorInt int titleColorActive, titleColorInactive; private @ColorInt int coloredTitleColorActive, coloredTitleColorInactive; private float titleActiveTextSize, titleInactiveTextSize; private int bottomNavigationHeight; @@ -159,12 +160,15 @@ public class AHBottomNavigation extends FrameLayout { bottomNavigationHeight = (int) resources.getDimension(R.dimen.bottom_navigation_height); // Item colors - itemActiveColor = ContextCompat.getColor(context, R.color.colorBottomNavigationAccent); - itemInactiveColor = ContextCompat.getColor(context, R.color.colorBottomNavigationInactive); + titleColorActive = ContextCompat.getColor(context, R.color.colorBottomNavigationAccent); + titleColorInactive = ContextCompat.getColor(context, R.color.colorBottomNavigationInactive); // Colors for colored bottom navigation coloredTitleColorActive = ContextCompat.getColor(context, R.color.colorBottomNavigationActiveColored); coloredTitleColorInactive = ContextCompat.getColor(context, R.color.colorBottomNavigationInactiveColored); + itemActiveColor = titleColorActive; + itemInactiveColor = titleColorInactive; + // Notifications notificationActiveMarginLeft = (int) resources.getDimension(R.dimen.bottom_navigation_notification_margin_left_active); notificationInactiveMarginLeft = (int) resources.getDimension(R.dimen.bottom_navigation_notification_margin_left); @@ -803,8 +807,8 @@ public class AHBottomNavigation extends FrameLayout { */ public void setColored(boolean colored) { this.colored = colored; - this.itemActiveColor = colored ? coloredTitleColorActive : itemActiveColor; - this.itemInactiveColor = colored ? coloredTitleColorInactive : itemInactiveColor; + this.itemActiveColor = colored ? coloredTitleColorActive : titleColorActive; + this.itemInactiveColor = colored ? coloredTitleColorInactive : titleColorInactive; createItems(); } @@ -842,6 +846,7 @@ public class AHBottomNavigation extends FrameLayout { * @param accentColor The new accent color */ public void setAccentColor(int accentColor) { + this.titleColorActive = accentColor; this.itemActiveColor = accentColor; createItems(); } @@ -861,6 +866,7 @@ public class AHBottomNavigation extends FrameLayout { * @param inactiveColor The inactive color */ public void setInactiveColor(int inactiveColor) { + this.titleColorInactive = inactiveColor; this.itemInactiveColor = inactiveColor; createItems(); } -- cgit v1.2.3