Skip to content Skip to sidebar Skip to footer

How To Obtain The Exact Dpi Value Of Android Device?

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?

Solution 1:

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().xdpigetResources().getDisplayMetrics().ydpi

Solution 2:

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

Post a Comment for "How To Obtain The Exact Dpi Value Of Android Device?"