【问题标题】:cordova app displays a black screen before splash screen displays科尔多瓦应用程序在启动画面显示之前显示黑屏
【发布时间】:2016-08-25 14:51:58
【问题描述】:

我正在使用英特尔 XDK 开发一个 Web 应用程序,它使用 Cordova 在线构建我的应用程序。 我使用启动画面插件添加了启动画面。当我启动我的应用程序时,会出现启动画面。但在启动画面显示之前,黑屏会先显示一会儿。我怎样才能让它在没有黑屏的情况下立即显示启动画面。

我用谷歌搜索了好几天......我发现很多其他人都有这个问题。但似乎解决方案无法帮助我..

我已尝试将 AutoHideSplashScreen 设置为 false 和 SplashScreenDelay = 10000(或更高),并在一切准备就绪时隐藏启动画面(app.Ready、deviceready..)

任何帮助将不胜感激,谢谢。

【问题讨论】:

  • 请提供更多信息。错误发生在哪个设备上?
  • 这不是错误,所有设备在加载cordova时都会发生这种情况

标签: cordova splash-screen


【解决方案1】:

我遇到了同样的问题,文档有点脱节。

Config.XML 确保您有以下几行。 Android:根据需要调整超时时间。(对我来说是 10000,因为我在 DOM 中预加载了一些页面)。

 <preference name="SplashScreen" value="screen" />
 <preference name="SplashScreenDelay" value="10000" />

IOS:

<preference name="FadeSplashScreen" value="false" />
<preference name="SplashScreen" value="screen" />
<preference name="AutoHideSplashScreen" value="false" />

在 Index.Js 中

function () {
document.addEventListener('deviceready', onDeviceReady.bind(this), false);
function onDeviceReady() {
setTimeout(function () {
        navigator.splashscreen.hide();
    }, 50);
}

这会让启动画面保持打开状态,直到平台为我准备好。

【讨论】:

    【解决方案2】:

    经过大量研究,我解决了这个问题。

    首先进入intelxdk.config.additions.xml文件

    在顶部添加这一行

    &lt;preference name="SplashScreenDelay" value="8000" /&gt;//根据您的需要更改值,以毫秒为单位

    同时修改 FadeSplashScreenDuration (iOS)

          `<preference name="FadeSplashScreenDuration" value="8000"/>`
    

    这是完整的代码

    <!-- 'value' = number of milliseconds to display the splash screen in a Cordova build. -->
    <!-- This preference only affects Cordova builds for Crosswalk and Android. -->
     <preference name="SplashScreenDelay" value="8000" /> 
    
    <platform name="ios">
        <!-- below requires the splash screen plugin -->
        <!-- docs: https://github.com/apache/cordova-plugin-splashscreen -->
        <preference name="AutoHideSplashScreen" value="false" />
        <preference name="FadeSplashScreen" value="false"/>
        <preference name="FadeSplashScreenDuration" value="8000"/>
        <preference name="ShowSplashScreenSpinner" value="true"/>
    
        <!-- below requires the status bar plugin -->
        <!-- docs: https://github.com/apache/cordova-plugin-statusbar -->
        <!-- see http://devgirl.org/2014/07/31/phonegap-developers-guid -->
        <preference name="StatusBarOverlaysWebView" value="false" />
        <preference name="StatusBarBackgroundColor" value="#000000" />
        <preference name="StatusBarStyle" value="lightcontent" />
    </platform>
    
    <platform name="android">
        <!-- below requires the splash screen plugin -->
        <!-- docs: https://github.com/apache/cordova-plugin-splashscreen -->
          <preference name="ShowSplashScreenSpinner" value="true"/>
        <preference name="SplashMaintainAspectRatio" value="true" />
    </platform>
    
    <!-- use this feature to add command-lines to be used by Crosswalk builds on device -->
    <!-- see http://peter.sh/experiments/chromium-command-line-switches/ for complete list -->
    <intelxdk:crosswalk xwalk-command-line="--disable-pull-to-refresh-effect" />
    <!-- ignore gpu blacklist for larger collection of gpu accelerated devices -->
    <intelxdk:crosswalk xwalk-command-line="--ignore-gpu-blacklist" />
    

    【讨论】:

      【解决方案3】:

      1) 如果您使用一些 splashscreen.png,您可以在 {Project}\res\values 下创建 android 样式文件(例如 splashscreen-style.xml)和将 splashscreen.png 放入 {Project}\res\drawable 文件夹(或 drawable-mdpi, drawable-xhdpi, ...),它会自动映射到 >@drawable/splashscreen

      <?xml version="1.0" encoding="utf-8"?>
      <resources>
          <style name="YourThemeName" parent="android:style/Theme.Light.NoTitleBar.Fullscreen">
              <item name="android:windowBackground">@drawable/splashscreen</item>
          </style>
      </resources>
      

      2) 通过 config.xml 应用您的:

          <edit-config file="AndroidManifest.xml" mode="merge"
                   target="/manifest/application/activity">
              <activity android:theme="@style/YourThemeName" />
          </edit-config>
      

      它必须工作,至少对于 cordova 6.5.0:) 和 一些更早的版本

      你也可以看到https://simonerescio.it/en/2014/05/phonegap-android-splashscreen-application

      【讨论】:

        【解决方案4】:

        转到 confi.xml 并尝试此代码。它对我有用。

        <access origin="*" />
        <preference name="SplashScreen" value="screen"/>
        <preference name="UIWebViewBounce" value="false" />
        <preference name="DisallowOverscroll" value="true" />
        <preference name="SplashScreenDelay" value="5000"/>
        <preference name="FadeSplashScreenDuration" value="5000"/> 
        <preference name="AutoHideSplashScreen" value="true"/>
        <preference name="SplashShowOnlyFirstTime" value="false"/>
        <preference name="FadeSplashScreen" value="false" /> 
        
        
        
        <!-- Ionic supports Android Jellybean and up --> 
        <preference name="android-minSdkVersion" value="16" />
        
        <!-- Don't store local data in an iCloud backup. Turn this to "cloud" to enable storage 
             to be sent to iCloud. Note: enabling this could result in Apple rejecting your app.
        -->
        <preference name="BackupWebStorage" value="none" />
        
        <feature name="StatusBar">
          <param name="ios-package" value="CDVStatusBar" onload="true" />
        </feature>
        <feature name="SplashScreen">
          <param name="ios-package" value="CDVSplashScreen"/>
          <param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen"/>
          <param name="onload" value="true"/>
        </feature>
        

        【讨论】:

          【解决方案5】:

          转到 platform/android/AndroidMainfest.xml 。 并搜索 android:theme="android:style/Theme.DeviceDefault.NoActionBar"。

          Android will load a blank layout before it loads based on the theme you have set for it. The solution is to the theme of the splash activity to a transparent one.
          

          并把它改成这样 android:theme="android:style/Theme.Translucent.NoActionBar"。

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2020-10-01
            • 1970-01-01
            • 2021-01-02
            • 1970-01-01
            • 2021-07-28
            • 2020-11-17
            • 2016-11-12
            相关资源
            最近更新 更多