简体   繁体   English

如何将分辨率转换为dpi

[英]How to convert resolution to dpi

I did my analysis and found that most of the users of my application will be of samsung galaxy S2, and samsung galaxy note . 经过分析,发现我的应用程序的大多数用户将使用三星银河S2和三星银河note。 Doing research on their technical spec, I found: Galaxy S2: 480 x 800 pixels, 4.3' display 通过研究他们的技术规格,我发现:Galaxy S2:480 x 800像素,4.3英寸显示屏

Galaxy Note: 1280 x 800, 5.3”screen Galaxy Note:1280 x 800,5.3英寸屏幕

How can I categorize these into Layout size and desnity level? 如何将它们分类为布局尺寸和外观等级? I think I can figure out the layout size as mentioned in the android development page However I am unable to know the density level (low, medium high xhigh). 我想我可以算出android开发页面中提到的布局大小,但是我不知道密度级别(低,中高x高)。 They say that I need the dpi but in functional spec, I rarely see the dpi, I just see the above resolution Thank you 他们说我需要dpi,但在功能规格上,我很少看到dpi,我只看到上面的分辨率谢谢

Calculate the density first Density=Square root((wp*wp)+(hp*hp))/di 首先计算密度密度=平方根((wp * wp)+(hp * hp))/ di

where wp is width resolution in pixels, hp is height resolution in pixels and di is diagonal size in inches. 其中wp是以像素为单位的宽度分辨率,hp是以像素为单位的高度分辨率,di是以英寸为单位的对角线尺寸。 It would come ~208 for S2. S2大约为208。

ldpi ~120dpi,mdpi ~160dpi, hdpi~240dpi, xhdpi ~320dpi . ldpi〜120dpi,mdpi〜160dpi,hdpi〜240dpi,xhdpi〜320dpi Compare from these values of dpi 从dpi的这些值进行比较

Not sure if I understand you correctly but you can request the density level and the dpi from the DisplayMetrics class. 不知道我是否理解正确,但是您可以从DisplayMetrics类中请求密度级别和dpi。 Using resolution and density you can approximate the display's size. 使用分辨率和密度,您可以近似显示的尺寸。

DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM