'What exactly is the difference between physical density and physical density of a device?
I have created a function to calculate diagonal screen size based on the resolution and pixel density. viz-
def find_display_size(d):
width=float(720);
height=float(1280);
dens=float(294);
wi=float(width)/(dens);
hi=float(height)/(dens);
x = math.pow(wi,2);
y = math.pow(hi,2);
screenInches = math.sqrt(x+y);
diagScreenSizeRoundedoff = round(screenInches)
logger.info("screenInches "+str(screenInches),also_console=True)
logger.info("diagScreenSizeRoundedoff"+str(diagScreenSizeRoundedoff),also_console=True)
I want to fetch the information (resolution & pixel density) using adb shell. When I am trying this command-
$adb shell wm density
Result-
Physical density: 320
The result I am getting is the physical density of a device(=320), however the pixel density of the particular device is (~294). Curious to know what exactly is the difference between these two, also how I can find the pixel density using adb commands which is ~294 in this case.
PS- The device I am working on is- MOTO XT1068
Solution 1:[1]
Android is fitting your device to one of group mdpi, hdpi, xhdpi etc. which have fixed density set. e.g. devices with 290-340 dpi will use 320 value, xxhdpi will be 480, mdpi only 160. This density is used for fetching data from resources (dimens, for calculating xml drawables, resizing drawable when is only in mhdpi folder, but device is xxdpi etc.) More densities and about topic in HERE
Screen density
The quantity of pixels within a physical area of the screen; usually referred to as dpi (dots per inch). For example, a "low" density screen has fewer pixels within a given physical area, compared to a "normal" or "high" density screen.
For simplicity, Android groups all actual screen densities into six generalized densities: low, medium, high, extra-high, extra-extra-high, and extra-extra-extra-high.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |