根据不同屏幕尺寸动态调整背景图片大小

发布于 2024-10-25 03:39:01 字数 57 浏览 2 评论 0原文

我的应用程序加载时显示启动屏幕,启动屏幕中有背景图像,我的问题是如何使该图像适合所有类型的黑莓型号?

I displays a splash Screen when my app loads,There is a background image in the splash screen,I problem is how can I make fit this image in all types of blackberry models?

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

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

发布评论

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

评论(2

梦醒灬来后我 2024-11-01 03:39:01

请记住,许多 BlackBerry 设备具有不同的屏幕分辨率,甚至不同的宽高比。因此,如果您仅使用单个图像并调整其大小(拉伸和/或挤压)以适合当前屏幕,则会扭曲图像(或图案)。在我看来,有两种主要方法:

1)为每个屏幕分辨率使用不同的图像。大约有 7 种不同的分辨率,涵盖了大多数市场设备(240x260、240x320、320x240、360x400、360x480、480x320、480x360)

2)如果它是常规背景图案而不是图片或徽标,则只需一张图像在应用程序中足够大以覆盖最大的屏幕尺寸(480x360),对于所有其他屏幕尺寸,只需剪辑它即可。事实上,我认为如果您只设置背景图像,这应该会自动发生 - 任何无法在屏幕上显示的内容都会被剪掉。

虽然方法 #2 在减少应用程序大小方面更好,但我猜测既然你问这个问题,你正在考虑使用的背景不是常规模式。

Keep in mind that many BlackBerry devices have different screen resolutions and even different aspect ratios. So if you just use a single image and resize (stretch and/or squish) it to fit the current screen, you're going to distort the image (or pattern). As I see it, there are two main approaches:

1) Use a different image for each screen resolution. There are about 7 different resolutions that cover most of the in-market devices (240x260, 240x320, 320x240, 360x400, 360x480, 480x320, 480x360)

2) If it's a regular background pattern as opposed to a picture or logo, just have one image in the app that's big enough to cover the largest screen size (480x360) and for all other screen sizes just clip it. In fact, I think this should happen automatically if you just set the background image - anything that can't be displayed on the screen will be clipped.

While approach #2 is better in terms of reducing application size, I'm going to guess that since you're asking this question the background you're thinking of using isn't a regular pattern.

極樂鬼 2024-11-01 03:39:01

我认为最简单的方法是使用任何需要拉伸背景的屏幕/字段的 setBorder 方法。例如:

Border b = BorderFactory.createBitmapBorder (new XYEdges (), bitmap);
field.setBorder(b);

根据我的经验,这会导致背景图像被拉伸,并提供最简单的方法来适应您需要的尺寸。我只将它用于字段,但从未将其用于主屏幕,因此它可能不适合您。

I think the simplest method would be to use the setBorder method of whatever screen/field needs a stretched background. For example:

Border b = BorderFactory.createBitmapBorder (new XYEdges (), bitmap);
field.setBorder(b);

In my experience this results in the background image being stretched and provides the simplest method for fitting the size you need. I have only ever used it for fields though and never a MainScreen so it might not work for you.

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