cordova-plugin-splashscreen使用及问题

该插件用于配置cordova项目图标及启动页

安装

cordova plugin add cordova-plugin-splashscreen
// or
cordova plugin add https://github.com/apache/cordova-plugin-splashscreen.g

设置启动页及图标

根目录下config.xml

<platform name="android">
    <allow-intent href="market:*" />
    <icon density="ldpi" src="res/icon/android/mipmap-ldpi/icon.png" />
    <icon density="mdpi" src="res/icon/android/mipmap-mdpi/icon.png" />
    <icon density="hdpi" src="res/icon/android/mipmap-hdpi/icon.png" />
    <icon density="xhdpi" src="res/icon/android/mipmap-xhdpi/icon.png" />
    <icon density="xxhdpi" src="res/icon/android/mipmap-xxhdpi/icon.png" />
    <icon density="xxxhdpi" src="res/icon/android/mipmap-xxxhdpi/icon.png" />
    <splash src="res/screen/android/splash.jpg" />
</platform>

页面完成隐藏启动页

根目录下config.xml设置启动页持续时间

<preference name="SplashScreenDelay" value="5000" />

html加载完成时隐藏

document.addEventListener("deviceready", () => {
    navigator.splashscreen.hide();
})

启动黑屏

引入插件后启动app先显示黑屏在显示启动页

修改根目录\platforms\android\AndroidManifest.xml下主题为透明

android:theme="@android:style/Theme.DeviceDefault.NoActionBar"
android:theme="@android:style/Theme.Translucent"