开发者

How to obtain the exact dpi value of android device?

开发者 https://www.devze.com 2023-04-09 11:17 出处:网络
we can use DisplayMetrics.densityDpi to obtain a approximate dpi value of the device,but i eager to know how to obtain the exact dpi val开发者_StackOverflowue? Use DisplayMatrics.xdpi and DisplayMatri

we can use DisplayMetrics.densityDpi to obtain a approximate dpi value of the device,but i eager to know how to obtain the exact dpi val开发者_StackOverflowue?


Use DisplayMatrics.xdpi and DisplayMatrics.ydpi

xdpi    The exact physical pixels per inch of the screen in the X dimension.
ydpi    The exact physical pixels per inch of the screen in the Y dimension.

getResources().getDisplayMetrics().xdpi
getResources().getDisplayMetrics().ydpi


I think you can accesss this through the class DisplayMetrics and the field densityDpi.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号