其中屏幕尺寸/密度的组合,我应该为位图的背景图像支持? [英] Which screen size / density combinations should I support for bitmap background image?

查看:263
本文介绍了其中屏幕尺寸/密度的组合,我应该为位图的背景图像支持?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写一个应用程序,我需要一些全屏位图的背景。基于rel=\"nofollow\">支持多种屏幕在Android文档中的我 [小,正常,大,超大] 和 [LDPI,MDPI,华电国际的,xhdpi] 。这应该减少CPU具有缩放图像做的工作,但会以极快的存储成本。

I'm writing an application where I will need a number of full screen bitmap backgrounds. Based on my naive reading of Supporting Multiple Screens in the Android documentation, to cover all my bases I should probably have 16 versions of each bitmap: all pairs of [ small, normal, large, xlarge ] and [ ldpi, mdpi, hdpi, xhdpi ]. This should reduce the work the CPU has to do for scaling the images, but will come at great storage cost.

不过,这似乎有两个原因似地低效:

However, this seems wildly inefficient for two reasons:


  1. 并非所有这些组合在实践中找到。

  2. 当我只是来表达每一个物理尺寸矢量图(不考虑DPI的尊重),喜欢大/ MDPI和正常/华电国际对(这两者都是〜480x854像素)的重复文件。

所以,我应该只是提供真正大的图像,并让系统扩展下来?硬着头皮,并提供了大量重复的图片?完全避免这个问题,并凑齐与原材料资源,一些code解决方案?任何其他的想法?谢谢你。

So, should I just provide really large images and let the system scale them down? Bite the bullet and provide a lot of duplicate images? Avoid the issue altogether and cobble some code solution with raw resources? Any other ideas? Thanks.

编辑:显然,你可以创建XML的位图资源而别名的实际的位图。这解决了第二个低效率的说法。不过,我不知道,什么这些组合都他人实践提供?

Apparently you can create XML bitmap drawables which alias an actual bitmap. That solves the second inefficiency argument. Still, I wonder, what combinations of these do others provide in practice?

推荐答案

如果你要那件艺术品是一个固定的大小,无论是显示在屏幕DPI的话,你只要提供不同分辨率的图像。图标或按钮将是这样的一个例子。

You would only provide images at different resolutions if you want that piece of art to be a constant size, regardless of the screen dpi it is displayed on. An icon or a button would be an example of this.

有关这里所描述的背景图片,你不在乎形象dpi是什么 - 你只关心X * Y尺寸是什么。所以,你不具备生产规模与DPI的跨产品。你只需要考虑4屏幕尺寸类别。

For the background images described here, you don't care what the image dpi is -- you only care what the x * y dimensions are. So you don't have to produce the cross-product of sizes vs. dpi. You only need consider the 4 screen size categories.

和4屏幕尺寸类别中,你只需要在需要存储大尺寸(XLARGE或大)之一,让框架的规模向上或向下。你也可以做缩放编程,以确保你不改变你的背景的纵横比,你不裁剪。

And within the 4 screen size categories, you only need store one of the larger sizes (xlarge or large) and let the framework scale that up or down as needed. You can also do the scaling programmatically, to ensure that you don't change the aspect ratio of your background, and you don't crop it.

另请参见的Andr​​oid游戏所有的屏幕上工作尺寸,以能吸引更好的答案。

See also Android game working on all screen sizes which will hopefully attract a better answer.

这篇关于其中屏幕尺寸/密度的组合,我应该为位图的背景图像支持?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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