【问题标题】:cordova plugin splash screen not working科尔多瓦插件启动画面不起作用
【发布时间】:2018-02-23 06:41:32
【问题描述】:

我正在使用 cordova-plugin-splashscreen 来显示启动画面。

https://www.npmjs.com/package/cordova-plugin-splashscreen

它以前可以工作,但不适用于新版本。这是我的配置文件:

<?xml version='1.0' encoding='utf-8'?>
   <widget id="in.fifa" version="1.0" versionCode="005" xmlns:gap = "http://phonegap.com/ns/1.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
   <name>FIFA18</name>
   <description>
       Sample Description
   </description>
   <author email="dev@cordova.apache.org" href="http://cordova.io">
       Author Name
    </author>
   <content src="index.html" />
   <plugin name="cordova-plugin-whitelist" version="1"/>
   <plugin name="cordova-plugin-splashscreen"/>
   <platform name="android">
      <splash src="screen.png" density="port-hdpi"/>
      <splash src="screen.png" density="port-ldpi"/>
      <splash src="screen.png" density="port-mdpi"/>
      <splash src="screen.png" density="port-xhdpi"/>
   </platform>
   <icon src="icon.png" /> 

   <preference name="SplashScreenDelay" value="1500"/>
   <preference name="FadeSplashScreen" value="false"/>
   <preference name="Orientation" value="portrait"/>
   <preference name="LoadUrlTimeoutValue" value="40000"/>
   <preference name="StatusBarOverlaysWebView" value="true"/>

   <access origin="*" />
   <allow-navigation href="*" />  
   <allow-intent href="http://*/*" />
   <allow-intent href="https://*/*" />
   <allow-intent href="tel:*" />
   <allow-intent href="sms:*" />
   <allow-intent href="mailto:*" />
   <allow-intent href="geo:*" />
   <platform name="android">
      <allow-intent href="market:*" />
      <preference name="android-minSdkVersion" value="15"/>
      <preference name="android-targetSdkVersion" value="23"/>
      <preference name="multiDexEnabled" value="true"/>
   </platform>
   <platform name="ios">
      <allow-intent href="itms:*" />
      <allow-intent href="itms-apps:*" />
   </platform>

启动画面图像在项目根文件夹中可用。是否有任何代码需要更改?谢谢!

【问题讨论】:

    标签: cordova cordova-plugins


    【解决方案1】:

    确保您的“screen.png”位于您的 cordova 项目文件夹中。如果您已将文件移动到 YOUR_CORDOVA_PROJECT/res/img/screen/screen.png 之类的位置,则需要在 config.xml 中尊重该路径,如下所示:

    <splash src="res/img/screen/screen.png" density="port-hdpi" />
    

    如果这不能解决问题,请确保您的 config.xml 结构与本示例中的结构相匹配:

    <?xml version= ... ?>
    <widget id= ...>
        ...
        <platform name="android">
            <splash src="path/to/screen.png" density="port-ldpi" />
            <splash src="path/to/screen.png" density="port-mdpi" />
            ...
        </platform>
        ...
    </widget>
    

    同时确保您没有在设备上以横向模式测试启动画面,因为您在提供的代码 sn-p 中仅添加了纵向模式的配置。

    【讨论】:

    • 我已经编辑了我的初始答案,以更清楚地反映 config.xml 结构。如果这没有帮助,您是否可以在此处发布 config.xml 的内容?另外,您确定已将启动画面图像存储在项目根文件夹中吗?这将是非常不典型的,您应该考虑将它们移动到提供的 res/ 文件夹中。
    • 我认为您需要将所有包含density 属性的&lt;splash&gt; 标签放在&lt;platform name="android"&gt; ... &lt;/platform&gt; 标签内。 density 属性仅支持 android 平台。请参阅文档中的此示例:cordova.apache.org/docs/en/latest/reference/…
    猜你喜欢
    • 2017-09-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-01
    • 2018-06-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多