-
1、在config.xml文件中修改配置
<preference name="ShowSplashScreen" value="true" />
<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="3000" />
<preference name="AutoHideSplashScreen" value="false" />
<preference name="SplashShowOnlyFirstTime" value="false" />
<preference name="FadeSplashScreen" value="false" />
<feature name="SplashScreen">
<param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen" />
</feature>
ShowSplashScreenSpinner——是否显示启动屏转圈圈那个 Spinner;
AutoHideSplashScreen——是否自动隐藏SplashScreen;
FadeSplashScreen——是否逐渐消失SplashScreen;
SplashScreenBackgroundColor——背景颜色;
SplashMaintainAspectRatio——如果值设置为 true,则图像将不会伸展到适合屏幕。如果设置为 false ,它将被拉伸;
FadeSplashScreenDuration——逐渐消失SplashScreen的动画时延;
SplashShowOnlyFirstTime——是否只第一次显示;
SplashScreen——它是 platform / android / res / drawable - 文件夹中的图像的名称。Cordova默认生成 screen.png 图片;
SplashScreenDelay——SplashScreen显示的延时时间
-
2、在app.component.ts中隐藏初始加载图片
constructor(public platform: Platform,
public statusBar: StatusBar,
public splashScreen: SplashScreen,
public backButtonService: BackButtonProvider,
) {
this.initializeApp();
}
initializeApp() {
this.platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
this.statusBar.styleDefault();
// this.splashScreen.hide();
// 隐藏初始加载图片
setTimeout(() => {
this.splashScreen.hide();
}, 1000);
this.backButtonService.registerBackButtonAction(null);
});
}
-
3、打包优化
ionic cordova build android --prod