您的位置:首页 > 移动开发 > Android开发

android 对超大屏幕尺寸的支持

2010-08-04 09:18 295 查看
最近碰到一个问题,就是在获取超大屏幕尺寸的时候,android API返回的尺寸是错误的,获取尺寸的代码确定是没问题的,但是每次返回的结果都是错误的。



这个问题让人百思不得其解。然后就查找相关文档,终于在android docs中发现一篇关于android 屏幕支持的文章,从中我得到了答案和解决方法。



大家可以在android sdk目录下面找到这篇文章 docs/guide/practices/screens_support.html#defaults



android 有一张标准屏幕对照表,由于我的是超大屏幕,屏幕的密度,尺寸都超过了这张标准对照表中的数据。所以其不能正常工作。



表格如下,详细内容可以参阅这篇文档。



The range of screens supported by Android and the generalized screen
configurations that the platform maps them to are shown in the table below.

Low density (120), ldpi

Medium density (160), mdpi

High density (240), hdpi

Small
screen
QVGA (240x320), 2.6"-3.0" diagonal

Normal
screen
WQVGA (240x400), 3.2"-3.5" diagonal

FWQVGA (240x432), 3.5"-3.8" diagonal

HVGA (320x480), 3.0"-3.5" diagonal

WVGA (480x800), 3.3"-4.0" diagonal

FWVGA (480x854), 3.5"-4.0" diagonal

Large
screen
WVGA (480x800), 4.8"-5.5" diagonal

FWVGA (480x854), 5.0"-5.8" diagonal

Table
1.

Summary of device screens supported by Android.

解决方法就是:

在AndroidManifest.xml中添加一个元素节点

如下

<manifest



xmlns:android

=

"http://schemas.android.com/apk/res/android"

>



<supports-screens



android:largeScreens

=

"true"



android:normalScreens

=

"true"



android:smallScreens

=

"true"



android:resizable

=

"true"



android:anyDensity

=

"true"



/>



</manifest>

这段的意思就是 可以支持小,中,大,以及各密度的屏幕。

然后就可以正常取得屏幕尺寸了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: