Skip to content

Instantly share code, notes, and snippets.

@TobiAlbert
Last active January 22, 2019 21:51
Show Gist options
  • Select an option

  • Save TobiAlbert/5563359d72d199864a9eac49371d7bc1 to your computer and use it in GitHub Desktop.

Select an option

Save TobiAlbert/5563359d72d199864a9eac49371d7bc1 to your computer and use it in GitHub Desktop.
public class BottomNavigationViewHelper {
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);
item.setShiftingMode(false);
item.setChecked(item.getItemData().isChecked());
}
} catch (NoSuchFieldException e) {
Log.e("BottomNavigationViewHelper", "Unable to get shift mode field", e);
} catch (IllegalAccessException e) {
Log.e("BottomNavigationViewHelper", "Unable to change value of shift mode", e);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment