简体   繁体   English

如何使用sw限定词为“小型”设备创建布局?

[英]How to create layout for “small” devices with sw qualifier?

As I understand layout-small , layout-normal , layout-large are deprecated and the recommended way of creating layout for a devices' set is to use sw. 据我了解,不建议使用layout-smalllayout-normallayout-large ,建议为设备集创建布局的方法是使用sw。 For example layout-sw320 is for devices which have one of it's side with value >= 320dp. 例如, layout-sw320适用于一侧值大于等于320dp的设备。 But "small" and "normal" devices have the same sw. 但是“小型”和“普通”设备具有相同的sw。

So the question is how properly distinguish "small" and "normal" devices with sw qualifier? 因此,问题是如何用sw限定词正确区分“小型”和“普通”设备? Is it possible? 可能吗? Do I need to fall back to old style ? 我需要退回到旧样式吗?

The new device dimension classifiers aim to support based on the smallest width of the device; 新的设备尺寸分类器旨在基于设备的最小宽度进行支持。 not so much the height. 没有那么高。 If your application is relying on the height, you will have to support the orientations separately or disable them using the screenOrientation property in the AndroidManifest.xml <activity> attribute. 如果您的应用程序依赖于高度,则必须单独支持方向,或者使用AndroidManifest.xml <activity>属性中的screenOrientation属性禁用它们。

For example, using screenOrientation="sensorPortrait|portrait" allows you to rely on the swXXX only, but if you support all screen orientations you can support them with: 例如,使用screenOrientation="sensorPortrait|portrait"允许您依赖swXXX ,但如果支持所有屏幕方向,则可以通过以下方式支持它们:

  • layout-w320-port , which is called for small and large screens in the old specification when in portrait layout-w320-port ,在纵向模式下,纵向和纵向都需要使用small屏幕 large屏幕
  • EDIT: You could use layout-w320-h426-port and layout-w320-h470-port when you want to differentiate between the two in portrait mode specifically. 编辑:当您想在纵向模式下专门区分两者时,可以使用layout-w320-h426-portlayout-w320-h470-port
  • layout-w426-land for the previous small screen, when in landscape orientation 当横向放置时,前一个small屏幕的layout-w426-land
  • layout-w470-land for the previous large screen, when in landscape orientation 当采用横向时,前一个large屏幕的layout-w470-land

Source 资源

Hope this helps! 希望这可以帮助!

in manifest - 在清单中-

<supports-screens android:resizeable=["true"| "false"]
                  android:smallScreens=["true" | "false"]
                  android:normalScreens=["true" | "false"]
                  android:largeScreens=["true" | "false"]
                  android:xlargeScreens=["true" | "false"]
                  android:anyDensity=["true" | "false"]
                  android:requiresSmallestWidthDp="integer"
                  android:compatibleWidthLimitDp="integer"
                  android:largestWidthLimitDp="integer"/>

check the link - http://developer.android.com/guide/topics/manifest/supports-screens-element.html and http://developer.android.com/guide/practices/screens_support.html 检查链接-http://developer.android.com/guide/topics/manifest/supports-screens-element.htmlhttp://developer.android.com/guide/practices/screens_support.html

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

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