Skip to content Skip to sidebar Skip to footer

How To Create An Avd With Android Studio To Preview A Real Device?

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) ~

Solution 1:

Find your AVD folder.

C:\users\<user>\.android\avd

Open the folder for the device and edit line:

hw.lcd.density=320

in

config.ini

While you have calculated 294 ppi, 294 is not allowed. Allowed values are:

120, 160, 213, 240, 280, 320, 360, 400, 420, 480, 560, 640

Please note, that those are densities:

0.75, 1, 1.33, 1.5, ...

Please note that 1.33 does not fit the Android list of ldpi, mdpi, hdpi, ...

It was needed so there was a value between mdpi and hpdi. I suspect there was hardware which had 213 ppi displays but hardward specs routinely change. Phones today are getting bigger while keeping the same pixel count, so a 4.5", 213 ppi phone from a few years ago has been replaced by a 5", 196 ppi phone.

The hardware factory sets the logical density at whatever number they like but if sensible they set it as close to the physical density as possible. So, a device will be set at 213 even though it's really 196.

Unfortunately, this leads to problems like you have encountered. Since you say the physical screen size gives a resolution of 294 ppi it is likely the hardware was set at density 1.75 (280 ppi). This is 5% less than the physical ppi but it is common for devices to report logical densities that different to physical densities (for example, 213 is 8% larger than 196).

Because 280 is exactly half way between 240 hdpi and 320 xhdpi I don't know how it will scale views. The emulator may render your layout perfectly but it may be using drawables from the hdpi folder. Your client's hardware may select drawables from the xhdpi folder which will scale them very differently.

Post a Comment for "How To Create An Avd With Android Studio To Preview A Real Device?"