找回旧的BottomBar [英] Getting back the old BottomBar
本文介绍了找回旧的BottomBar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
仅启动了一个新应用,当包含 BottomNavigationView
时,结果如下所示:
Just started a new app and when including a BottomNavigationView
the result look like that :
我真的不知道它来自哪里,如何回到仍在规范
I really don't get where it come from and how can I get back to the old version that are still defined in the spec
有人知道这些变化的来源吗?
Does someone know where these changes come from ?
推荐答案
默认情况下,当BottomNavigationView包含3个以上项目时,添加shiftingmode = true。因此,请尝试以下操作
by default BottomNavigationView add shiftingmode = true when its more than 3 items. so try this
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 ", "Unable to get shift mode field"+e);
} catch (IllegalAccessException e) {
Log.e("ERROR", "Unable to change value of shift mode"+e);
}
}
BottomNavigationView bottomNavigationView = (BottomNavigationView)findViewById(R.id.bottomBar);
BottomNavigationViewHelper.removeShiftMode(bottomNavigationView);
这篇关于找回旧的BottomBar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文