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();
  });
}
...
上一篇:javascript-HTML5视频要等到源更新后才能播放


下一篇:javascript-实时视频广播