簡體   English   中英

是否可以在config.xml中的Cordova 3.5中定義啟動屏幕?

[英]Is it possible to define splash screens in Cordova 3.5 in config.xml?

我很難找到文檔來檢查是否可以使用config.xml定義初始屏幕?

我沒有在Git上跟蹤./platform目錄,所以我放在那里的所有內容僅在我的計算機上可用,在其他團隊成員中不可用。

我想做這樣的事情:

<gap:splash gap:density="ldpi" gap:platform="android" src="res/screen/android/screen-ldpi-portrait.png" />
<gap:splash gap:density="mdpi" gap:platform="android" src="res/screen/android/screen-mdpi-portrait.png" />
<gap:splash gap:density="hdpi" gap:platform="android" src="res/screen/android/screen-hdpi-portrait.png" />
<gap:splash gap:density="xhdpi" gap:platform="android" src="res/screen/android/screen-xhdpi-portrait.png" />
<gap:splash gap:platform="blackberry" src="res/screen/blackberry/screen-225.png" />

可能?

好的,由於我沒有這個問題的答案,因此我將發布對我有用的解決方案。

使用Cordova的鈎子( after_prepare ),我能夠將啟動畫面文件從/www復制到正確的Android和iOS平台目錄。

該掛鈎位於/hooks/after_prepare/030_resource_files.js ,在准備步驟后立即由Cordova執行。

這是我的代碼最后的樣子:

#!/usr/bin/env node

// Reference: http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/

//
// This hook copies various resource files from our version control system directories into the appropriate platform specific location
//

var appName = "MyAwesomeApp";

// configure all the files to copy.  Key of object is the source file, value is the destination location.  It's fine to put all platforms' icons and splash screen files here, even if we don't build for all platforms on each developer's box.
var filestocopy = [{
  "www/res/screens/android/drawable/splash.png": "platforms/android/res/drawable/splash.png"
},{
  "www/res/screens/android/drawable-hdpi/splash.png": "platforms/android/res/drawable-hdpi/splash.png"
}, {
  "www/res/screens/android/drawable-ldpi/splash.png": "platforms/android/res/drawable-ldpi/splash.png"
}, {
  "www/res/screens/android/drawable-mdpi/splash.png": "platforms/android/res/drawable-mdpi/splash.png"
}, {
  "www/res/screens/android/drawable-xhdpi/splash.png": "platforms/android/res/drawable-xhdpi/splash.png"
}, {
  "www/res/screens/ios/Resources/splash/Default@2x~iphone.png": "platforms/ios/" + appName + "/Resources/splash/Default@2x~iphone.png"
}, {
  "www/res/screens/ios/Resources/splash/Default-568h@2x~iphone.png": "platforms/ios/" + appName + "/Resources/splash/Default-568h@2x~iphone.png"
}, {
  "www/res/screens/ios/Resources/splash/Default~iphone.png": "platforms/ios/" + appName + "/Resources/splash/Default~iphone.png"
}];

var fs = require('fs');
var path = require('path');

// no need to configure below
var rootdir = process.argv[2];

filestocopy.forEach(function(obj) {
  Object.keys(obj).forEach(function(key) {
    var val = obj[key];
    var srcfile = path.join(rootdir, key);
    var destfile = path.join(rootdir, val);
    //console.log("copying "+srcfile+" to "+destfile);
    var destdir = path.dirname(destfile);
    if (fs.existsSync(srcfile) && fs.existsSync(destdir)) {
      fs.createReadStream(srcfile).pipe(fs.createWriteStream(destfile));
    }
  });
});

仍然相當困難得到它的工作,因為有很多有適合一起為它工作片,但它是幫助我解決我的問題掛鈎。

來源:Holly Schinsky的文章的“ 復制圖標和啟動畫面”部分非常有用,我從以下地方獲取了大部分代碼: http ://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project -需要/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM