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

如何让自己开发的android支持多种不同的手机屏幕(supporting Multiple Screens)

2012-03-05 18:58 585 查看
转换式为:px=dp*(dpi/160)



其中px为最终显示的像素数目;dp为density-independent pixel,即A virtual pixel unit that you should use when defining UI layout, to express layout dimensionsor position in a density-independent way. The density-independent pixel is
equivalent to one physical pixel on a 160 dpi screen, which isthe baseline density assumed by the system for a "medium" density screen. At runtime, the systemtransparently handles any scaling of the dp units, as necessary, based on the actual density of thescreen
in use. The conversion of dp units to screen pixels is simple:


px = dp * (dpi / 160)
.;dpi为目标手机的实际像素密度(Screen density)

证明:设两个不同屏幕上的一段等长距离a,原始图对应width值为dp,目标屏幕密度为dpi,最终在屏幕显示的像素数目为x,则有a=dp/160=x/dpi。变形即有所示转换式。

原文链接
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: