From 388534bec48f8b47a3d6847b5200b8cfe22297c2 Mon Sep 17 00:00:00 2001 From: Aurelien Hubert Date: Mon, 4 Apr 2016 19:45:15 +0200 Subject: Fixed the backgroundView height --- .../aurelhubert/ahbottomnavigation/AHBottomNavigation.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation') diff --git a/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigation.java b/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigation.java index cacbd01..4e2a3f7 100644 --- a/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigation.java +++ b/ahbottomnavigation/src/main/java/com/aurelhubert/ahbottomnavigation/AHBottomNavigation.java @@ -136,12 +136,15 @@ public class AHBottomNavigation extends FrameLayout { } else if (items.size() > MAX_ITEMS) { Log.w(TAG, "The items list should not have more than 5 items"); } + + int layoutHeight = (int) resources.getDimension(R.dimen.bottom_navigation_height); + removeAllViews(); views.clear(); backgroundColorView = new View(context); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && colored) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { LayoutParams backgroundLayoutParams = new LayoutParams( - ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); + ViewGroup.LayoutParams.MATCH_PARENT, layoutHeight); addView(backgroundColorView, backgroundLayoutParams); } @@ -149,7 +152,6 @@ public class AHBottomNavigation extends FrameLayout { linearLayout.setOrientation(LinearLayout.HORIZONTAL); linearLayout.setGravity(Gravity.CENTER); - int layoutHeight = (int) resources.getDimension(R.dimen.bottom_navigation_height); LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, layoutHeight); addView(linearLayout, layoutParams); @@ -422,6 +424,7 @@ public class AHBottomNavigation extends FrameLayout { items.get(itemIndex).getColor(context)); } else { setBackgroundColor(defaultBackgroundColor); + backgroundColorView.setBackgroundColor(Color.TRANSPARENT); } } else if (i == currentItem) { @@ -519,6 +522,7 @@ public class AHBottomNavigation extends FrameLayout { items.get(itemIndex).getColor(context)); } else { setBackgroundColor(defaultBackgroundColor); + backgroundColorView.setBackgroundColor(Color.TRANSPARENT); } } else if (i == currentItem) { @@ -938,6 +942,7 @@ public class AHBottomNavigation extends FrameLayout { updateNotifications(true); } + //////////////// // INTERFACES // //////////////// -- cgit v1.2.3