其他分享
首页 > 其他分享> > android-科尔多瓦在显示启动画面时隐藏状态栏

android-科尔多瓦在显示启动画面时隐藏状态栏

作者:互联网

通过插件cordova-plugin-splashscreen显示启动画面.但是,当应用程序启动并显示初始屏幕时,状态栏不会被隐藏.显示启动画面时如何隐藏状态栏?我找到了这个解决方案:

How to completely hide the status bar in iOS using Cordova?

但是它可以在iOS上运行.我的平台是Android.

解决方法:

在ionic 3应用中,如果< preference name =“ Fullscreen” value =“ true” />不起作用,请执行以下操作:

>安装全屏插件:

ionic cordova plugin add cordova-plugin-fullscreen
npm install --save @ionic-native/android-full-screen

>将其添加到config.xml文件中以自定义主题:

<widget ... xmlns:android="http://schemas.android.com/apk/res/android">   // note this xmlns:android line
    <platform name="android">
    ...
    <edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application/activity">
      <activity android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/>
    </edit-config>
  </platform>
</widget>

>在src / app / app.module.ts中添加全屏提供程序:

....
// add this line at the top of the file, import it
import {AndroidFullScreen} from "@ionic-native/android-full-screen";
...
providers: [
  StatusBar,
  SplashScreen,    
  {provide: ErrorHandler, useClass: IonicErrorHandler},
  AndroidFullScreen,   // here add this line
  ...
]

>在src / app / app.components.ts中使用它:

// add this line at the top of the file, import it
import {AndroidFullScreen} from "@ionic-native/android-full-screen";
...
constructor(public platform: Platform,
            public statusBar: StatusBar,
            public splashScreen: SplashScreen,
            public androidFullScreen: AndroidFullScreen) {

  // show statusbar
  this.androidFullScreen.isSupported()
    .then(() => this.androidFullScreen.showSystemUI());

  // style statusbar and hide splash
  this.platform.ready().then(() => {
      this.statusBar.styleDefault();
      this.splashScreen.hide();
  });
}
...

标签:cordova,cordova-plugins,android
来源: https://codeday.me/bug/20191111/2022798.html