7

在我的应用程序中,我支持手机/平板电脑的外形尺寸并拥有单独的布局,我使用选择器“layout”(用于手机)、“layout-sw600dp”(用于平板电脑)。

以下是详细信息:

http://android-developers.blogspot.in/2011/07/new-tools-for-managing-screen-sizes.html

Typical numbers for screen width dp are:
320: a phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc).
480: a tweener tablet like the Streak (480x800 mdpi).
600: a 7” tablet (600x1024).
720: a 10” tablet (720x1280, 800x1280, etc).

我有一个 Nexus 4 手机,以下是它的属性

Size:       4.7 inches
Resolution: 768 x 1280 pixels
DPI:        318
dp:         386 
Here is the dp calculation
dp = (px * 160)/dpi
dp = (768 * 160)/318

当我在 dp 计算公式中使用 768 px 时,dp 值为 386,但当我通过 1280 px 时,dp 值为 644。

有了以下理解,我认为 Nexus 4 景观会从 sw600dp 读取布局,但事实并非如此。

由于分辨率为宽 X 高,旋转设备时会反转。

我认为这是 sw 选择器与 3.2 之前的大型、xlarge 扇区相比的即兴创作。

4

2 回答 2

19

As it says in the Android documentation here in bold (scroll down a bit to the "smallestWidth" section of Table 2):

The smallestWidth is a fixed screen size characteristic of the device; the device's smallestWidth does not change when the screen's orientation changes.

于 2013-06-26T07:10:57.487 回答
9

无论设备方向如何,sw 数字始终是两个屏幕尺寸中较短的一个。这就是名称“smallestWidth”中的“smallest”的来源。与姜饼式“大”等相比的优势。选择器只是让您获得更精细的控制,并且更可预测您实际获得的屏幕尺寸,因为它不依赖于制造商如何对他们的屏幕尺寸进行分类。

如果要根据当前方向的屏幕宽度或高度选择布局,请使用名为layout-w600dpor的目录layout-h600dp

于 2013-10-13T10:53:43.897 回答