Open ahmedmoussa8 opened 7 years ago
after some searches on this problem, I've found a solution but for BottomNavigationView . Can we use it here?
static void removeShiftMode(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);
// set once again checked value, so view will be updated
item.setChecked(item.getItemData().isChecked());
}
} catch (NoSuchFieldException e) {
Log.e("ERROR NO SUCH FIELD", "Unable to get shift mode field");
} catch (IllegalAccessException e) {
Log.e("ERROR ILLEGAL ALG", "Unable to change value of shift mode");
}
}
I also have clients that are asking to have the "shifting" mode disabled. Putting in my +1 to have this supported in the library <3
You can use this library instead: https://github.com/ittianyu/BottomNavigationViewEx I have used it and it's working as charming.
+1 for a request to add this feature!
@ssawchenko I kinda found a hack. Suppose you have 5 icons in the navbar, try using
bottomNavigation.setTitleState(AHBottomNavigation.TitleState.ALWAYS_SHOW);
This removes the shifting animation.
freplace this value in app's manifest:
<dimen name="bottom_navigation_margin_top_inactive" tools:override="true">6dp</dimen>
<dimen name="bottom_navigation_text_size_active" tools:override="true">12sp</dimen>
You can find the original value is:
<dimen name="bottom_navigation_margin_top_active">6dp</dimen>
<dimen name="bottom_navigation_margin_top_inactive">8dp</dimen>
<dimen name="bottom_navigation_text_size_active">14sp</dimen>
<dimen name="bottom_navigation_text_size_inactive">12sp</dimen>
So, just override these values with yours :)
also you can setTitleSize(activesize, inactivesize)
override dimens with
<dimen name="bottom_navigation_small_selected_width_difference">0.1dp</dimen>
@ssawchenko I kinda found a hack. Suppose you have 5 icons in the navbar, try using
bottomNavigation.setTitleState(AHBottomNavigation.TitleState.ALWAYS_SHOW);
This removes the shifting animation.
it works for me
Great work, How could I remove shifting mode of the item selected? Thanks.