简体   繁体   English

xlarge vs sw720dp屏幕尺寸混乱

[英]xlarge vs sw720dp screen size confusion

For reference: http://developer.android.com/guide/practices/screens_support.html 供参考: http//developer.android.com/guide/practices/screens_support.html

The old style size quantifiers are "deprecated": 旧样式大小量词是“已弃用”:

A set of four generalized sizes: small, normal, large, and xlarge Note: Beginning with Android 3.2 (API level 13), these size groups are deprecated in favor of a new technique for managing screen sizes based on the available screen width. 一组四种通用尺寸:小尺寸,普通尺寸,大尺寸和xlarge注意:从Android 3.2(API级别13)开始,不推荐使用这些尺寸组,而采用基于可用屏幕宽度管理屏幕尺寸的新技术。 If you're developing for Android 3.2 and greater, see Declaring Tablet Layouts for Android 3.2 for more information. 如果您正在为Android 3.2及更高版本开发,请参阅为Android 3.2声明平板电脑布局以获取更多信息。

I was hoping that devices with 3.2+ would still use resources declared in drawable-large-mdpi, or layout-xlarge, but this doesn't seem to be the case. 我希望3.2+的设备仍然使用drawable-large-mdpi或layout-xlarge中声明的资源,但似乎并非如此。

I have a test project that contains a layout file for each of these sizes: 我有一个测试项目,其中包含以下每种尺寸的布局文件:

  • layout-sw600dp 布局sw600dp
  • layout-720dp 布局720dp
  • layout-xlarge 布局XLARGE
  • layout 布局

On a 10" Motorola XOOM running Android 4.0.x, the device picks the layout in the layout-720dp folder. If that folder doesn't exist, it picks the layout in the layout-sw600dp folder! Why doesn't it pick the layout in layout-xlarge? 在运行Android 4.0.x的10“Motorola XOOM上,设备选择layout-720dp文件夹中的布局。如果该文件夹不存在,它会在layout-sw600dp文件夹中选择布局! 为什么不选择layout-xlarge中的布局?

Even more strange, is I have drawables in these folders: 更奇怪的是,我在这些文件夹中有drawable:

  • drawable-sw600dp-mdpi 提拉 - sw600dp-MDPI
  • drawable-xlarge-mdpi 提拉 - XLARGE,MDPI

The 10" Motorola XOOM from above, picks the image from drawable-sw600dp-mdpi. Why doesn't it pick the drawable in drawable-xlarge-mdpi? 从上面的10“摩托罗拉XOOM,从drawable-sw600dp-mdpi中选择图像。 为什么不在drawable-xlarge-mdpi中选择drawable?

Should we not expect the xlarge quantifier to work at all above Android 3.2? 我们不应该期望xlarge量词在Android 3.2之上完全有效吗?

Does this mean I have to duplicate all assets in the drawable-xlarge-mdpi folder, into the drawable-sw720dp-mdpi folder? 这是否意味着我必须将drawable-xlarge-mdpi文件夹中的所有资产复制到drawable-sw720dp-mdpi文件夹中? (To support Android 3.0, 3.1 AND 3.2+?) (支持Android 3.0,3.1和3.2+?)

Hopefully I am just missing something simple here. 希望我在这里错过了一些简单的东西。 Please advise. 请指教。

From my understanding, for Android 3.2+, if you have at least one folder that uses the new size quantifiers then it assumes that you are using these new size quantifiers everywhere. 根据我的理解,对于Android 3.2+,如果你有至少一个使用新大小量词的文件夹,那么它假定你在各地使用这些新的大小量词。 So this is the reason why it ignores layout-xlarge or any other folder that uses the old quantifiers. 所以这就是它忽略layout-xlarge或任何其他使用旧量词的文件夹的原因。

With regard to backward compatibility, you'll have to use in your project both types of quantifiers. 关于向后兼容性,您必须在项目中使用两种类型的量词。 The old ones will be used for API < 3.2 and the new ones for API >= 3.2. 旧的将用于API <3.2,新的用于API> = 3.2。 To avoid duplication, for the layouts you can use aliases. 为避免重复,对于布局,您可以使用别名。 However, for drawables, I don't know of any solution to avoid duplication. 但是,对于drawables,我不知道有任何避免重复的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM