和layout-400dp-land之间的区别

桑杰·辛格(Sanjay Singh)

该应用程序的要求是它应该在所有设备上都可以运行。为了支持这一点,我有

以下布局定义-

layout/
layout-land/
layout-sw400dp-port/
layout-sw400dp-land/
layout-sw600dp-port/
layout-sw600dp-land/
layout-sw7200dp-port/
layout-sw7200dp-land/

适用于7英寸和10英寸平板电脑。

对于sw400dp设备,例如5英寸设备(如Samsung Note等),它们正在使用layout/layout-land/。如何强制这些设备使用layout-sw400dp-port/layout-sw400dp-land/

肯·沃尔夫

你不能

原始的Note运行GingerBread(2.3),并且sw-标识符仅在3.2以上的版本中起作用。

http://developer.android.com/guide/practices/screens_support.html#support

可用于提供特定于大小的资源的配置限定符为small,normal,large和xlarge。例如,超大屏幕的布局应放在layout-xlarge /中。

从Android 3.2(API级别13)开始,不建议使用上述大小组,而应使用swdp配置限定符

<3.2的设备将不使用-sw布局。为了支持所有API级别,您将需要使用两种类型的限定符来提供布局。

看看这篇文章:http : //android-developers.blogspot.co.uk/2011/07/new-tools-for-managing-screen-sizes.html

平台的早期版本将使用新的资源限定符忽略任何资源。因此,这是一种可行的方法:

res/layout/main_activity.xml           # For phones
res/layout-xlarge/main_activity.xml    # For pre-3.2 tablets
res/layout-sw600dp/main_activity.xml   # For 3.2 and up tablets

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章