Ionic 4-隐藏Android导航栏(底部)

时间:2020-07-27 18:48:42

标签: android angular ionic-framework ionic4 android-navigation-bar

当离子输入具有焦点时,它将显示导航栏。更改焦点后,导航栏将隐藏。 这是代码。

在app.component.ts中使用

this.androidFullScreen.isImmersiveModeSupported().then(() => this.androidFullScreen.immersiveMode());

在signUp页面上,我有2个输入字段。单击第一个字段时,离子输入具有焦点,并在底部显示导航栏。

已经尝试过(ionFocus)=“ hideNavigationBar()”

hideNavigationBar() {
   this.androidFullScreen.setSystemUiVisibility(AndroidSystemUiFlags.LayoutStable | 
   AndroidSystemUiFlags.LayoutHideNavigation | AndroidSystemUiFlags.HideNavigation);
}

此外,尝试在显示软键盘时隐藏导航栏。

this.keyboard.onKeyboardWillShow().subscribe(()=> { 
this.keyboard.hide();
this.androidFullScreen.setSystemUiVisibility(
          AndroidSystemUiFlags.HideNavigation |
          AndroidSystemUiFlags.LayoutHideNavigation |
          AndroidSystemUiFlags.Immersive |
          AndroidSystemUiFlags.LayoutStable);
});

但是仍然显示导航栏。 有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

您可以使用cordova插件来实现。

安装

ionic cordova plugin add cordova-plugin-navigationbar
npm install @ionic-native/navigation-bar

代码侧

import { NavigationBar } from '@ionic-native/navigation-bar/ngx';

constructor(private navigationBar: NavigationBar) { }

...

let autoHide: boolean = true;
this.navigationBar.setUp(autoHide);

详细说明在这里。 https://ionicframework.com/docs/native/navigation-bar

相关问题