1) Create a splash screen image or icon
Ionic resources//simultaneous generation of icon and splash
Ionic Resources--icon//Generate icon only
Ionic Resources--splash//Generate Splash Only
If the generated icon/splash is damaged, Cordova build Android will error, the solution is to regenerate or another PS;
2) Add two configuration items to config. ins in the project root directory:
<preference name= "SplashScreen" value= "Splash"/>
<preferencename= "Splashscreendelay" value= "30000"/>
Where the first configuration specifies the file name of the splash screen, and the second setting specifies the time in milliseconds for the splash screen to stay.
3) Add the processing function to the homepage:
document.addEventListener ("deviceready", onDeviceReady, false);
// Cordova will trigger when loading is complete
function onDeviceReady () {
navigator.splashscreen.hide ();
}
The value of the above configuration item Splashscreendelay is recommended to be as large as possible, such as 20000 (20 seconds). According to my understanding, the Start screen display, the first page is still under normal loading (that is, the program will not wait until the splash screen disappears before starting to load the first page); If the set delay value is too small, such as 3000 (3 seconds), and the first page load needs 5000 (5 seconds), then the screen will be in the black screen state When you set a value that is larger than the first page load time value, the red line of code hides the splash screen in advance.
Cordova application to modify the splash screen or icon