但是经过试验,我发现那些文章提到的方法都不好用。。。splash screen确实会出现,但是它出现以后界面会黑一下,然后才是web页面。无论
- super.loadUrl(“file:///android/www/index.html”, 1000)
复制代码
参数里面的delay 时间加到多长。
看过phonegap的代码,
- super.setIntegerProperty(“splashscreen”,
- R.drawable.splash)
复制代码
实际上干的事情是 1. 把appview的背景颜色设透明。 2. 把appview的背景设成指定的图片。 然后在web页面被load成功以后,将appview的背景删去。 界面会黑一下的原因我觉得是它删的太早了。
所以加splash screen,并且不黑的最终解决方案:
1. 在activity的onCreate方法中。 loadUrl之前加上
- this.appView.setBackgroundColor(0);
- this.appView.setBackgroundResource(R.drawable.splashscreen)
复制代码
第一句是把背景色设成透明。 第二句是设置背景为指定的图片(参数即为想要的图片)
2. 在js代码中。当所有的该load的东西全部load成功以后,将要显示web页面之前。把页面背景色设为白色(或其他颜色)
- $(‘body’).css(‘background’,’white’);
复制代码
这一句是Jquery代码。看不懂的可以查查Jquery语法。
注:图片放到在res 图片的目录,各放一个splashscreen的图片!
========================================
用dw5.5里直接生成后找到目录地址 com.company.ganqi_Android》res,里面共有三个文件夹drawable-ldpi\
drawable-ldpi\drawable-mdpi, 分别把里面的splash.png图片换成你想要的图片就行了
==============================================
phonegap-1.4.1。。下
this.appView.setBackgroundColor(0);
this.appView.setBackgroundResource(R.drawable.splashscreen)
这两段不行。
而
super.setIntegerProperty(“splashscreen”,
R.drawable.splash)
这就行
========================================
phonegap2.0 也是这样super.setIntegerProperty(“splashscreen”, R.drawable.splash) 才行,而
01.this.appView.setBackgroundColor(0);
02.this.appView.setBackgroundResource(R.drawable.splashscreen)
这两行不好使
转载请注明:夜阑小雨 » 给使用phonegap的Android程序加上splash screen(启动图片 预览图))