How to obtain the exact dpi value of android device?

前端 未结 2 1541
既然无缘
既然无缘 2021-01-21 14:23

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 value?

相关标签:
2条回答
  • 2021-01-21 14:53

    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
    
    0 讨论(0)
  • 2021-01-21 15:00

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

    0 讨论(0)
提交回复
热议问题