有没有办法让dpi的屏幕尺寸 [英] Is there a way to get screen size in dpi
问题描述
我用这样的:
INT无线= getWindowManager()getDefaultDisplay()的getWidth()。
获取屏幕尺寸以像素为单位。有没有办法让 dpi的屏幕尺寸
???
我在做这个选择屏幕尺寸不同布局的基础。
有没有办法让以dpi为escreen大小???
块引用>
DisplayMetrics
可以告诉你,在像素的屏幕尺寸,加上屏幕密度。从那里,你可以在DP
计算的屏幕尺寸。
我在做这个选择屏幕尺寸不同布局的基础。
块引用>这是自动为您的资源框架来处理,如果你把你的布局在正确的目录(例如,
RES /布局大/
,RES /布局sw600dp /
)。I'm using this:
int wi=getWindowManager().getDefaultDisplay().getWidth();
to get the screen size in pixels. Is there a way to get the screen size in
dpi
???I'm doing this to select different layouts base on the screen size.
解决方案Is there a way to get the escreen size in dpi???
DisplayMetrics
can tell you the screen size in pixels, plus the screen density. From there, you can calculate the screen size indp
.I'm doing this to select different layouts base on the screen size.
This is automatically handled for you by the resource framework, if you put your layouts in the proper directories (e.g.,
res/layout-large/
,res/layout-sw600dp/
).这篇关于有没有办法让dpi的屏幕尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!