我正在使用cordova webview来包装我的在线webapp。
我需要为cordova webview设置背景。
显然,指定android:background属性不适用于cordova webview。 所以我正在寻找一种为cordova webview设置背景的方法。
包装图片或网页对我来说都没问题。
Here是我刚才提出的相关问题。并且如答案所示,我可以使用缓存提前加载网页。但是它是在运行时完成的。我现在需要的是刻录背景或缓存到应用程序中。
答案 0 :(得分:1)
尝试使用Cordova初始屏幕。 API位于:http://docs.phonegap.com/en/edge/cordova_splashscreen_splashscreen.md.html#Splashscreen
public class splashScreen extends DroidGap
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
//super.loadUrl("file:///android_asset/www/index.html");
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl("http://www.google.com",10000);
}
}
确保您创建splash.png
图片并将其保存在/res/drawable/
文件夹中。
这应该会在外部URL加载时在WebView上显示“背景”,而不是仅显示黑屏。