Reputation: 153
I'm trying to create a bottom navigation bar but the buttons are moving to the right
how can fix the view in the bottom navigation bar to look like this?
Upvotes: 1
Views: 1039
Reputation: 373
If you need like that one, You need set ShiftMode following like :
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);
} 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);
}
}
And send your Buttom NavigationView :
BottomNavigationView bottomNavigationView = (BottomNavigationView) findViewById(R.id.navigation);
disableShiftMode(bottomNavigationView);
That's all Thank you.
Upvotes: 2