【问题标题】:Application unable auto detect device screen size应用程序无法自动检测设备屏幕尺寸
【发布时间】:2012-05-11 09:55:10
【问题描述】:

我开发了一个应用程序。我做了两组布局,分别是

默认和小

所以我有 2 个布局文件夹,分别是 res/layout 和 res/layout-small。

我在 2.7 英寸 HVGA 的模拟器中进行了测试,它确实自动使用 res/layout-small 文件夹。

当我在设备上运行它时,它没有但仍在使用 res/layout。

这是我的 manifest.xml

<supports-screens
    android:anyDensity="true"
    android:largeScreens="true"
    android:normalScreens="true"
    android:resizeable="true"
    android:smallScreens="true"
    android:xlargeScreens="true"
    android:requiresSmallestWidthDp="480"
    android:compatibleWidthLimitDp="480"
    android:largestWidthLimitDp="480" >
</supports-screens>

为什么应用程序安装到设备后无法检测设备屏幕尺寸?

【问题讨论】:

  • 模拟器和设备上运行的 Android 版本。你用的是什么设备?
  • @bitbox,抱歉回复晚了,我的模拟器使用的是 1.6,它能够自动检测。我的设备使用的是 2.2.3 但无法检测到屏幕尺寸。但是,我的另一个设备 nexus 正在运行 4.0.3,它也能够检测到

标签: android android-screen-support


【解决方案1】:

复制自documentation

注意:这些最小屏幕尺寸在之前没有得到很好的定义 Android 3.0,所以你可能会遇到一些被错误分类的设备 在正常和大之间。这些也是基于物理的 屏幕分辨率,因此可能因设备而异——例如 带系统栏的 1024x720 平板电脑实际上空间较小 由于它被系统栏使用,因此可供应用程序使用。

如果您使用的不是 3.0+ 设备,那么这可能是设备的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多