布局和布局之间的区别-400dp-land

San*_*ngh 5 android android-layout android-screen android-screen-support

该应用程序的要求是它应该适用于所有设备.我支持这个

以下布局定义 -

layout/
layout-land/
layout-sw400dp-port/
layout-sw400dp-land/
layout-sw600dp-port/
layout-sw600dp-land/
layout-sw7200dp-port/
layout-sw7200dp-land/
Run Code Online (Sandbox Code Playgroud)

它适用于7"和10"平板电脑.

对于sw400dp设备,例如像Samsung Note等5"设备,他们正在使用layout/layout-land/.我如何强制使用这些设备 layout-sw400dp-port/layout-sw400dp-land/

Ken*_*olf 1

你不能

原始 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
Run Code Online (Sandbox Code Playgroud)