我在视图中添加了一个带有几个按钮的底部导航。但是,当我运行我的应用程序时,只显示导航栏的最顶部。当我把窗户加长时,我可以看到整个酒吧。当我将 AppBar 可见性设置为“false”时,导航栏就会很好地显示出来。如何正确显示底部导航?我是否将 BottomNavigation 对象添加到右视图?
这是我的大部分课程:
public void initialize() {
primary.showingProperty().addListener((obs, oldValue, newValue) -> {
if (newValue) {
AppBar appBar = getApp().getAppBar();
appBar.setNavIcon(MaterialDesignIcon.MENU.button(e ->
getApp().getDrawer().open()));
appBar.setTitleText("Gluon App");
}
});
primary.setBottom(createBottomNaviagtion());
}
public BottomNavigation createBottomNaviagtion(){
BottomNavigation bottomNavigation = new BottomNavigation();
//.. creating BottomNavigationButtons
bottomNavigation.getActionItems().addAll(/*Buttons here*/);
return bottomNavigation;
}
我意识到 GlassPane 包含一个 AppBar 和一个 View,就像我一直在向 View 添加 BottomNavigation 一样,我也可以向 View 添加一个 AppBar。当使 GlassPane 的 AppBar 不可见时,这会产生我想要的结果:AppBar 和 BottomNavigation 都很好地显示出来。不过,我仍然想知道这是否是正确的方法,任何反馈都将不胜感激!