我的 Android 启动画面应该是什么分辨率?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2561598/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 06:19:14  来源:igfitidea点击:

What resolution should my Android splash screens be?

androidresolutionsplash-screen

提问by Dan Fabulich

I'm creating a splash screen that will display while my Android application loads. I'd like to create it at the correct size so Android won't auto-scale it up or down to fit the screen. (It's a bitmap image, a photograph of an oil painting, so I can't just turn it into a nine-patch.)

我正在创建一个将在我的 Android 应用程序加载时显示的启动画面。我想以正确的尺寸创建它,这样 Android 就不会自动放大或缩小它以适应屏幕。(它是位图图像,一幅油画的照片,所以我不能把它变成九个补丁。)

But there are at least three important screen sizes I care about: 320x480, 480x854 (Droid), and 480x800 (Nexus One).

但我关心至少三个​​重要的屏幕尺寸:320x480、480x854 (Droid) 和 480x800 (Nexus One)。

I've read the documentation on supporting multiple screen sizes, but I still don't see how I'm supposed to configure different splash screens for Droid/Nexus one (they're both "hdpi" resources as far as Android is concerned), and I don't know exactly how large my splash screen should be in any case. (How tall is the OS title bar/menu in Droid? N1?)

我已经阅读了有关支持多种屏幕尺寸的文档,但我仍然不明白我应该如何为 Droid/Nexus one 配置不同的启动画面(就 Android 而言,它们都是“hdpi”资源) ,而且我不知道在任何情况下我的启动画面到底应该有多大。(Droid 中的操作系统标题栏/菜单有多高?N1?)

What size should I make these images, and how do I tell Android to use the correct size on a given screen?

我应该制作什么尺寸的这些图像,以及如何告诉 Android 在给定的屏幕上使用正确的尺寸?

回答by Christopher Orr

You don't need to worry about the absolute screen size or status bars or anything — that's why we have nine-patch images.

您无需担心绝对屏幕尺寸或状态栏或任何东西——这就是我们拥有九个补丁图像的原因。

What I did was have an image that looked good for each resolution — essentially a logo on a transparent background, with some text at the bottom.

我所做的是让图像在每种分辨率下看起来都不错——本质上是透明背景上的标志,底部有一些文字。

Then I chopped off quite a lot of space at the top and side edges, made a nine-patch border round the image, with a single pixel near the left, right and top edges. This allows the image to expand evenly at the sides and top to fill the screen.

然后我在顶部和侧边切掉了相当多的空间,在图像周围制作了一个九块边框,在左侧、右侧和顶部边缘附近有一个像素。这允许图像在两侧和顶部均匀扩展以填充屏幕。



Edit, in response to Dan's comment below:

编辑,以回应丹在下面的评论:

Yes, there is a way to determine which graphics should be used for which explicit screen sizes, but it's deprecated.

是的,有一种方法可以确定哪些图形应用于哪些显式屏幕尺寸,但已弃用

Just as there are drawable-hdpiand -ldpiresource qualifiers, it's also possible to use drawable-HHHxWWW— the larger pixel dimension coming first.

正如有drawable-hdpi-ldpi资源预选赛,它也可以使用drawable-HHHxWWW-更大的像素尺寸来第一次。

e.g. drawable-800x480and drawable-854x480

例如drawable-800x480drawable-854x480

回答by jqpubliq

Okay, firstly: you can find the device model via android.os.Buildand use that to determine which image to show.

好的,首先:您可以通过android.os.Build找到设备模型并使用它来确定要显示的图像。

Secondly, I personally wouldn't bother. Layouts should be done in dip since every android screen is 320x480 dip I believe, and android maintains aspect ratio among devices very well through this in my experience. A 480x800 splash set to fill parent has been pretty reliable on both N1 and the droid as far as I have encountered.

其次,我个人不会打扰。布局应该在dip中完成,因为我相信每个android屏幕都是320x480dip,并且根据我的经验,android通过这个很好地保持了设备之间的纵横比。就我遇到的情况而言,用于填充父级的 480x800 飞溅设置在 N1 和机器人上都非常可靠。

回答by Yoel Gluschnaider

Another solution that I implemented is to put an ImageView that fills the screen (width and height both "MATCH_PARENT") with scale type "centerCrop". This way, the image is not stretched but cropped along the edges. Try not to put important content (logos and stuff like that) close to the edges. If it is a photograph, I hope that the edges are "expendable" and can be cropped out.

我实现的另一个解决方案是放置一个 ImageView 填充屏幕(宽度和高度均为“MATCH_PARENT”),比例类型为“centerCrop”。这样,图像不会被拉伸,而是沿边缘裁剪。尽量不要把重要的内容(标志和类似的东西)放在靠近边缘的地方。如果是照片,希望边缘是“消耗品”,可以裁剪掉。