Android 多屏限定符定义 [英] Android multiple-screen qualifiers definitions

查看:76
本文介绍了Android 多屏限定符定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个与大量设备和屏幕兼容的布局.我一直在研究,我发现最常见的屏幕分辨率是 249x320、480x800、600x1024、720x1280(以及与这些成比例的其他一些屏幕).

I wanna create a layout compatible with a very large number of devices and screens. As I have been researching I found out that the most common screen resolutions are 249x320, 480x800, 600x1024, 720x1280 (and some other screens proportional to these).

好吧,在阅读文档后,我发现有两种方法可以做到.在 3.2 Android 版本之前,我可以使用小、普通、大、超大"等布局的限定符,并将它们与端口"(纵向)或陆地"(横向)结合起来.

Well, after reading the documentation I found out that there are two ways of doing it. Up to the 3.2 Android version I could use qualifiers for the layouts like "small, normal, large, xlarge" and combine them with "port" (portrait orientation) or "land" (landscape orientation".

现在,第二种方式(似乎是最推荐的)仅适用于 Android 3.2 及更高版本.无论屏幕方向如何 (???),您都必须指定必须使用布局的最小宽度.

Now, the second way (that seems to be the most recommended) is working only for Android 3.2 and later versions. You must specify the smallest width for which a layout must be used, no matter the screen orientation (???).

由于使用第二种方法时无法指定端口或土地限定符,因此我更喜欢第一种.我的问题是:第一种方法是否兼容Android 3.2及更高版本?我必须对 Android 使用第一种方法吗?3.2 和第二个 Android > 3.2?如果是这样,我应该创建两个项目,或者结合这两种方法(创建大约 10 个布局尺寸,用于一般尺寸限定符和特定最小宽度限定符).我想这需要更多资源.

For the fact that you cannot specify the port or land qualifiers when using the second method, I prefer the first one. My question is: is the first method compatible with Android 3.2 and later versions? Must I use the first method for Android < 3.2 and the second for Android > 3.2? If so, I should create two projects, or maybe combine these two methods (create about 10 layout sizes, for the general-size qualifiers and for the specific minimum-width qualifiers). That would need more resources, I suppose.

感谢并抱歉我的语言不好.

Thanks and sorry for my bad language.

推荐答案

在 Android 中,您不是根据像素设计布局……而是根据与密度无关的像素(dip 或 dp)来设计布局.这些是按设备每英寸屏幕密度的点数缩放的设备像素.Android 有 4 个通用屏幕密度桶,您必须在适当的文件夹下为每个桶提供可绘制对象(res/drawable-ldpi、res/drawable-mdpi、res/drawable-hdpi、res/drawable-xhdpi).

In Android you don't design your layouts based on pixels... you design them based on density independent pixels (dip or dp). These are device pixels scaled by the dots per inch screen density of your device. Android has 4 general screen density buckets, and you must provide drawables for each one under an appropriate folder (res/drawable-ldpi, res/drawable-mdpi, res/drawable-hdpi, res/drawable-xhdpi).

使您的布局与多种设备兼容的其他方法是使用 9png 可拉伸图形,并使用依赖 dp 来确定尺寸的 XML 可绘制对象.

Other ways to make your layout compatible with a multitude of devices is to use 9png stretchable graphics, and use XML drawables that rely on dp for their dimensions.

Android 屏幕支持推荐阅读:
http://developer.android.com/guide/practices/screens_support.html

Recommended reading for Android screen support:
http://developer.android.com/guide/practices/screens_support.html

至于最小宽度限定符,您忽略了最小宽度以 dp 而不是像素指定的事实.检查本节中的表 2:
http://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources

As far as the smallest-width qualifier, you are missing the fact that the smallest width is specified in dp, not pixels. Check Table 2 in this section:
http://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources

第一种方法适用于所有设备,包括 Android 3.2+.

The first method works on all devices, including Android 3.2+.

这篇关于Android 多屏限定符定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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