I have created an avd of Xiomi Redmi 3s (294dpi), whose specifications are:
The generalized densities in Android are:
- Ldpi (low) ~ 120 dpi -> dp = px * 0.74
- Mdpi (average) ~ 160 dpi -> dp = px * 1
- Hdpi (high) ~ 240 dpi -> dp = px * 1.5
- Xhdpi (extraalta) ~ 320 dpi -> dp = px * 2
- Xxhdpi (extra extraalta) ~ 480 dpi -> dp = px * 3
- Xxxhdpi (extra extra extraalta) ~ 640 dpi -> dp = px * 4
When I create the avd with device specifications, the assigned density is xhdpi (x2), but the actual device density factor is less than x2, as with most devices, so the preview result does not match the actual appearance of the device screen. For example, the same thing happens with the Nexus 5x, which has the resource density of xxhdpi (x3), but the actual density is 2.63
In Android Studio, emulated devices such as Nexus 5x or Pixel XL, specifies the special density of 420dpi and 560dpi respectively, where the density factor is 2.6 (xxhdpi) and 3.5 (xxxhdpi) approximately.
To determine the width dp and its density factor of the Xiomi Redmi 3S I have used:
dpi/160 = densityPxValue 294/160 = 1,8375
and I calculated the real density with https://stackoverflow.com/a/5104104/4114846
The result is the density of 294 dpi and the actual density factor is 1.83, but the resource folder assigned by the system is xhdpi (x2) and the preview corresponds to the generalized density.
How can I create an avd and preview by specifying the density of the device or its density factor so that it looks like the actual device ?
If you can not specify with android studio, what alternatives do we have?