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

来源:互联网 发布:软件项目风险分析报告 编辑:程序博客网 时间:2024/05/16 12:23

转换式为: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。变形即有所示转换式。




原文链接


原创粉丝点击