如何移除Cordova应用程序中的启动屏
Cordova 12.0.0 移除启动屏的有效方案
1. 检查并移除启动屏插件
Cordova的启动屏功能基本由cordova-plugin-splashscreen插件提供,先确认插件是否存在:
cordova plugin list
如果列表里有该插件,直接移除:
cordova plugin remove cordova-plugin-splashscreen
2. 清理config.xml中的启动屏配置
打开项目根目录的config.xml,删除或注释掉所有和启动屏相关的配置项,比如:
<preference name="SplashScreen" value="..." /><preference name="SplashScreenDelay" value="..." />- 所有
<splash>标签(定义各尺寸启动图的节点)
3. 修正Android平台默认启动背景(针对Android端)
Cordova 12的Android项目资源路径是platforms/android/app/src/main/res,而非根目录的res。如果移除插件后仍有启动屏,修改主题配置:
- 打开
res/values/styles.xml - 找到
AppTheme节点,将android:windowBackground改为透明:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <item name="android:windowBackground">@android:color/transparent</item> </style>
- 检查
AndroidManifest.xml中主Activity的android:theme属性,确保引用的是修改后的AppTheme
4. 修正iOS平台启动屏(针对iOS端)
- 打开
platforms/ios/[你的项目名]/Resources/splash,删除所有启动图片文件 - 回到
config.xml,确保已移除所有<splash>标签 - 重新构建iOS项目
最后验证
执行以下命令清理并重新构建项目:
cordova clean cordova build [android/ios]
内容的提问来源于stack exchange,提问作者Joker
相关产品推荐
相关产品推荐

