显示启动画面,直到PhoneGap加载主页

时间:2013-02-07 15:27:56

标签: cordova splash-screen

我创建了一个phonegap应用程序。加载主页面需要4秒钟(即index.html)。

在phonegap加载index.html之前,有什么方法可以显示一些图像/启动画面吗?

2 个答案:

答案 0 :(得分:4)

将启动画面设置为超出预期的值,可能是10秒。

然后在页面准备就绪后立即使用以下代码关闭它:

function onDeviceReady() {
    navigator.splashscreen.hide();
}

document.addEventListener("deviceready", onDeviceReady, false);

答案 1 :(得分:0)

这很简单。如果你把splash.png图像文件放入res / drawable-ldpi,res / drawable-mdpi,res / drawable-hdpi,res / drawable-xhdpi文件夹。然后在扩展DroidGap的主java类中添加以下行:

super.setIntegerProperty("splashscreen", R.drawable.splash);

然后修改loadUrl方法暂停5秒钟:

super.loadUrl("file:///android_asset/www/index.html", 5000);

快乐的编码。

相关问题