PhoneGap的 - 闪屏的Andr​​oid应用PhoneGap、Andr、oid

2023-09-11 11:53:17 作者:柚子小西

有谁请指教我怎么可以添加一个启动画面我的PhoneGap HTML5基于Android应用程序。我只是希望它显示5秒钟的负载。同时 - 有谁能够指教一下尺寸的闪屏应该是

Could anybody please advise how I can add a splash screen to my HTML5 Phonegap based Android App. I just want it to display for 5 seconds on load. Also - can anybody advise what dimensions the splash screen should be.

推荐答案

为了让在你需要把一个PhoneGap的Andr​​oid应用程序闪屏的 splash.png 文件转换成 RES /绘制-LDPI RES /绘制-MDPI RES / drawable-华电国际 RES /绘制-xhdpi 。如果这些目录重新present低,中,每英寸高和特大型点。您需要调整您splash.png(文件名是很重要的在这里)为每个目录或Android将延伸给你。

In order to have a splash screen in a PhoneGap Android application you need to put your splash.png file into res/drawable-ldpi, res/drawable-mdpi, res/drawable-hdpi, res/drawable-xhdpi. Where those directories represent low, medium, high and extra large dots per inch. You'll need to resize you splash.png (the file name is important here) for each directory or Android will stretch it for you.

每个图像的尺寸应该是:

The sizes of each image should be:

XLARGE(xhdpi):至少960×720 大(华电国际):至少640×480 在介质(MDPI):至少470×320 小(LDPI):至少426×320

然后在你的主Java类,一个扩展DroidGap,你需要添加一行,并修改另一个。先加:

Then in your main Java class, the one that extends DroidGap, you'll need to add one line and modify another. First add:

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

这条线应该在 super.onCreate 出现,但前 super.loadUrl 。然后,你需要修改你的使用loadURL方法加载了主要的页面之前暂停5秒。它是这样的:

this line should show up under super.onCreate but before super.loadUrl. Then you'll need to modify your loadUrl method to pause for 5 seconds before loading up the main page. It would look like this:

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

这应该为你做它。

我最近做了一些更新到闪屏的工作原理上PhoneGap的Andr​​oid系统。主要的应用程序现在加载启动屏幕正在显示时。这是一个很大的改进了previous阻塞闪屏通话。 了解更多关于在我的博客上的变化。

I've recently made some updates to how the SplashScreen works on PhoneGap Android. The main app now loads while the splash screen is being shown. This is a big improvement over the previous blocking splash screen call. Read more about the changes on my blog.