Reputation: 489
I'm trying to have ALL icons centered, I already disabled the shifting mode by using the following code:
/**
* This is done to remove the shift animation introduced by Android on the bottom navigation view
* https://stackoverflow.com/a/41690461/4243027
*/
@SuppressLint("RestrictedApi")
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);
item.setPadding(0,15,0,0);
// 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);
}
}
And set the title to ""
android:title=""
I have also tried to do the following https://stackoverflow.com/a/40234361/4243027 but it's not working either.
My bottom navigation view looks like this:
I'm using implementation "com.android.support:design:27.0.1"
EDIT:
As you can see in Layout Inspector, the icon sizes are the same, 63x63 px but the Y of the checked icon is 5 px less.
Upvotes: 4
Views: 2606
Reputation: 483
As of Design Support Library 28.0.0-alpha1 you can use the property
app:labelVisibilityMode="unlabeled"
Upvotes: 5