Phonegap 初始屏幕方向

发布于 2024-12-03 21:57:29 字数 93 浏览 0 评论 0原文

当为phonegap应用程序设置启动屏幕时,图片会拉伸到整个屏幕,即使我制作了一张徽标位于中心的大图片。理想情况下,我希望图片位于黑色或白色背景的中心。如何配置闪屏的行为?

When setting the splashscreen for a phonegap application, the picture gets stretched across the whole screen, even when i make a big picture with the logo in the center. Ideally I want the picture just sit in the center with a black or white background. How can I configure the behaviour of the splashscreen?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

残月升风 2024-12-10 21:57:29

有一个更好的解决方案:只需将以下splash.xml放入res/drawable中(修改android:src属性)并在setIntegerProperty()调用中更改对R.drawable.splash的引用。

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
  android:src="@drawable/splashImage"
  android:gravity="center_horizontal|center_vertical" />

请参阅我的博客有关设置的更详细说明。

There is a better solution available: Simply place the following splash.xml in res/drawable (modify the android:src attribute) and change the reference to R.drawable.splash, in the setIntegerProperty() call.

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
  android:src="@drawable/splashImage"
  android:gravity="center_horizontal|center_vertical" />

Please see my Blog for a more detailed description of the set-up.

開玄 2024-12-10 21:57:29

我只是根据启动时的当前方向设置启动屏幕。不完美,但有效。您可以更进一步,方向上的广告会改变相同的效果,但有人在启动屏幕启动期间改变方向的机会很小。

int ot = getResources().getConfiguration().orientation;

        if (ot == 2) {
            super.setIntegerProperty("splashscreen", R.drawable.splashlandscape);
            Log.d("Orientation", "Landscape");
        }
        else {
            super.setIntegerProperty("splashscreen", R.drawable.splashportrait);
            Log.d("Orientation", "Portrait");
        }

I just set the splash screen based on the current orientation on startup. Not perfect, but works. You could go further and ad on orientation change the same effect, but the chances of someone changing orientation during splash screen startup is slim.

int ot = getResources().getConfiguration().orientation;

        if (ot == 2) {
            super.setIntegerProperty("splashscreen", R.drawable.splashlandscape);
            Log.d("Orientation", "Landscape");
        }
        else {
            super.setIntegerProperty("splashscreen", R.drawable.splashportrait);
            Log.d("Orientation", "Portrait");
        }
梦魇绽荼蘼 2024-12-10 21:57:29

这是一个解决方案,但它有缺陷

,将您的splash.png放在各种可绘制文件夹中,

res/drawable/splash.png (480wx800h portrait version)
res/drawable-land/splash.png (800wx480h landscape version)

此方法的已知问题是如果加载后方向发生变化,它不会更新背景...(这对于phonegap 1.10来说是正确的)

This is a solution but it has flaws

put your splash.png in the various drawable folders

res/drawable/splash.png (480wx800h portrait version)
res/drawable-land/splash.png (800wx480h landscape version)

known issue with this method is if the orientation changes after load it doesn't update the background... (this is true for phonegap 1.10)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文