PhoneGap的 - 闪屏的Andr​​oid应用 [英] phonegap - splash screen for Android app

查看:154
本文介绍了PhoneGap的 - 闪屏的Andr​​oid应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁请指教我怎么可以添加一个启动画面我的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.

这篇关于PhoneGap的 - 闪屏的Andr​​oid应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆