Android Cordoba hides the status bar when the splash screen is displayed

The startup screen is displayed through the plug-in Cordova plugin splash screen. However, when the application starts and displays the initial screen, the status bar will not be hidden. How to hide the status bar when displaying the startup screen? I found this solution:

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

But it can run on IOS. My platform is Android

resolvent:

In ionic 3 applications, if < preference name = "fullscreen" value = "true" / > does not work, please do the following:

>To install the full screen plug-in:

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

>Add it to the config.xml file to customize the theme:

<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>

>Add a full screen provider in 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
  ...
]

>Use it in 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();
  });
}
...

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>