Cannot resolve method 'setShiftingMode(Boolean)' in BottomNavigationView Cannot resolve method 'setShiftingMode(Boolean)' in BottomNavigationView android android

Cannot resolve method 'setShiftingMode(Boolean)' in BottomNavigationView


Found the answer. In support library 28.0.0-alpha1 we can now add labels (remove shifting mode) using any one of the following methods:

XML:

<android.support.design.widget.BottomNavigationView        .        .        .        app:labelVisibilityMode="labeled" />

Code:

mBottomNavigationView.setLabelVisibilityMode(LabelVisibilityMode.LABEL_VISIBILITY_LABELED);

Or:

@SuppressLint("RestrictedApi")public static void removeNavigationShiftMode(BottomNavigationView view) {    BottomNavigationMenuView menuView = (BottomNavigationMenuView) view.getChildAt(0);    menuView.setLabelVisibilityMode(LabelVisibilityMode.LABEL_VISIBILITY_LABELED);    menuView.buildMenuView();}