phone应用 - Android应用的启动屏幕 [英] phonegap - splash screen for Android app

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

问题描述

任何人都可以告诉我如何添加一个启动画面到我的基于HTML5 PhoneGap的Android应用程序。我只是希望在载入时显示5秒。另外 - 任何人都可以告诉你什么维度的启动屏幕应该是。

解决方案

为了在PhoneGap Android应用程序中有一个启动屏幕您需要将 splash.png 文件放入 res / drawable-ldpi res / drawable-mdpi res / drawable-hdpi res / drawable-xhdpi 。那些目录表示每英寸低,中,高和超大点数。您将需要调整大小,您可以为每个目录或Android安装splash.png(文件名称很重要)。



每个图像的大小应该是:




  • xlarge(xhdpi):至少960 x 720

  • large(hdpi)至少640 x 480

  • medium(mdpi):至少470 x 320

  • small(ldpi):至少426 x 320



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

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

此行应显示在 super.onCreate 但在 super.loadUrl 之前。那么你需要修改你的loadUrl方法来暂停5秒钟,然后再加载主页面。它将如下所示:

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

应该为你做。



我最近对SplashScreen在PhoneGap Android上的工作做了一些更新。当显示启动屏幕时,主应用程序现在加载。这比以前的屏幕截屏调用有了很大的改进。 详细了解我博客上的更改


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.

解决方案

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): at least 960 x 720
  • large (hdpi): at least 640 x 480
  • medium (mdpi): at least 470 x 320
  • small (ldpi): at least 426 x 320

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);

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);

That should do it for you.

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.

这篇关于phone应用 - Android应用的启动屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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