public static void disableShiftMode(BottomNavigationView view) { BottomNavigationMenuView menuView = (BottomNavigationMenuView)view.GetChildAt(0); try { for (int i = 0; i < menuView.ChildCount; i++) { BottomNavigationItemView item = (BottomNavigationItemView)menuView.GetChildAt(i); //noinspection RestrictedApi item.SetShiftingMode(false); // set once again checked value, so view will be updated //noinspection RestrictedApi item.SetChecked(item.ItemData.IsChecked); } } catch (NoSuchFieldException e) { //Log.("BNVHelper", "Unable to get shift mode field", e); } catch (IllegalAccessException e) { // Log.e("BNVHelper", "Unable to change value of shift mode", e); } }
public void DisableShiftMode(BottomNavigationView v) { var menu = (BottomNavigationMenuView)((ViewGroup)v).GetChildAt(0); var shiftingMode = menu.Class.GetDeclaredField("mShiftingMode"); shiftingMode.Accessible = true; shiftingMode.SetBoolean(menu, false); shiftingMode.Accessible = false; for (int i = 0; i < menu.ChildCount; i++) { BottomNavigationItemView item = (BottomNavigationItemView)menu.GetChildAt(i); item.SetShiftingMode(false); item.SetChecked(item.ItemData.IsChecked); //TextView var content = (BaselineLayout)item.GetChildAt(1); content.LayoutParameters = new Android.Widget.FrameLayout.LayoutParams(Android.Widget.FrameLayout.LayoutParams.MatchParent, Android.Widget.FrameLayout.LayoutParams.MatchParent); for (int j = 0; j < content.ChildCount; j++) { var tv = (AppCompatTextView)content.GetChildAt(j); tv.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); tv.SetTextSize(Android.Util.ComplexUnitType.Px, tv.TextSize * 1.2f); tv.TextAlignment = Android.Views.TextAlignment.Center; tv.Gravity = GravityFlags.Center; tv.Typeface = Android.Graphics.Typeface.DefaultBold; } item.RemoveView(item.GetChildAt(0)); } menu.UpdateMenuView(); }
public static void disableShiftMode(BottomNavigationView navigationView) { BottomNavigationMenuView menuView = (BottomNavigationMenuView)navigationView.GetChildAt(0); try { var shiftingMode = typeof(BottomNavigationMenuView).GetField("mShiftingMode"); //shiftingMode.setAccessible(true); //shiftingMode.setBoolean(menuView, false); //shiftingMode.SetValue(menuView, false); //shiftingMode.setAccessible(false); for (int i = 0; i < menuView.ChildCount; i++) { BottomNavigationItemView itemView = (BottomNavigationItemView)menuView.GetChildAt(i); itemView.SetShiftingMode(false); itemView.SetChecked(itemView.ItemData.IsChecked); } } catch (Exception ex) { throw; } }
public static void DisableShiftMode(BottomNavigationView view) { BottomNavigationMenuView menuView = (BottomNavigationMenuView)view.GetChildAt(0); try { var sm = menuView.Class.GetDeclaredField("mShiftingMode"); sm.Accessible = true; sm.SetBoolean(menuView, false); sm.Accessible = false; for (int i = 0; i < menuView.ChildCount; i++) { BottomNavigationItemView item = (BottomNavigationItemView)menuView.GetChildAt(i); item.SetShiftingMode(false); item.SetChecked(item.ItemData.IsChecked); } } catch (System.Exception) { } }
public static void DisableShiftMode(BottomNavigationView view) { BottomNavigationMenuView menuView = (BottomNavigationMenuView)view.GetChildAt(0); try { Java.Lang.Reflect.Field shiftingMode = menuView.Class.GetDeclaredField("mShiftingMode"); shiftingMode.Accessible = true; shiftingMode.SetBoolean(menuView, false); shiftingMode.Accessible = false; for (int i = 0; i < menuView.ChildCount; i++) { BottomNavigationItemView itemView = (BottomNavigationItemView)menuView.GetChildAt(i); itemView.SetShiftingMode(false); itemView.SetChecked(itemView.ItemData.IsChecked); } } catch (Exception ex) { BuglyUtil.PostException("unable to get shift mode field" + ex); } }
private void UpgradeTabbedItemsAppereance() { if (bottomTabBarItemsStateList == null) { InitializeBottomTabBarItemsStateList(); } if (ViewGroup != null && ViewGroup.ChildCount > 0) { BottomNavigationView bottomNavigationView = FindChildOfType <BottomNavigationView>(ViewGroup); bottomNavigationView.SetShiftMode(false, false); BottomNavigationMenuView bottomNavigationMenuView = FindChildOfType <BottomNavigationMenuView>(ViewGroup); for (int i = 0; i < bottomNavigationMenuView.ChildCount; i++) { BottomNavigationItemView item = (BottomNavigationItemView)bottomNavigationMenuView.GetChildAt(i); item.SetTextColor(bottomTabBarItemsStateList); item.SetShifting(false); item.SetLabelVisibilityMode(LabelVisibilityMode.LabelVisibilityLabeled); item.SetChecked(item.ItemData.IsChecked); Android.Views.View activeLabel = item.FindViewById(Resource.Id.largeLabel); if (activeLabel is TextView) { var font = Typeface.CreateFromAsset(_context.Assets, "Montserrat-SemiBold.ttf"); (activeLabel as TextView).Typeface = font; } Android.Views.View inActiveLabel = item.FindViewById(Resource.Id.smallLabel); if (activeLabel is TextView) { var font = Typeface.CreateFromAsset(_context.Assets, "Montserrat-SemiBold.ttf"); (inActiveLabel as TextView).Typeface = font; } } } T FindChildOfType <T>(ViewGroup viewGroup) where T : Android.Views.View { if (viewGroup == null || viewGroup.ChildCount == 0) { return(null); } for (var i = 0; i < viewGroup.ChildCount; i++) { var child = viewGroup.GetChildAt(i); var typedChild = child as T; if (typedChild != null) { return(typedChild); } if (!(child is ViewGroup)) { continue; } var result = FindChildOfType <T>(child as ViewGroup); if (result != null) { return(result); } } return(null); } }