#1 Daily Issues -Android
Hi friends ,
HereAfter i planned to put post daily about i am facing issues daily with solution, and if i see any new things ,i will post about that in the name of daily Suggestion.
Two days ago i faced the issue in the bottom navigation, when i added the more than three item in bottom navigation it shows the item text label in the shift manner.after exploring the google i find this.
get the Field of Shifting mode, and set that field false to all menu item of bottom navigation.then you can change the shift mode of the bottom navigation.
public static void disableShiftMode(BottomNavigationView view) {
BottomNavigationMenuView menuView = (BottomNavigationMenuView) view.getChildAt(0);
try {
Field shiftingMode = menuView.getClass().getDeclaredField("mShiftingMode");
shiftingMode.setAccessible(true);
shiftingMode.setBoolean(menuView, false);
shiftingMode.setAccessible(false);
for (int i = 0; i < menuView.getChildCount(); 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.getItemData().isChecked());
}
} catch (NoSuchFieldException e) {
Log.e("BNVHelper", "Unable to get shift mode field", e);
} catch (IllegalAccessException e) {
Log.e("BNVHelper", "Unable to change value of shift mode", e);
}
}
thanks and Happy Coding…
Happy coding!
Buy me a coffee?
If you like this article, you can buy me a coffee. Thanks!