Example #1
0
        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);
            }
        }
Example #2
0
        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();
        }
Example #3
0
        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);
            }
        }