So, as far as I know, we can use next formula:
density = SQRT(width*width+height*height)/screen_size.
For example, Nexus 6 (6.0", 1_440*2_560) should give 490 dpi (approx.), but Android Studio Preview screen shows this device with 560 dpi.
What am I missing?
Although each device has its own screen density, Android includes the device into the nearest density "bucket":
420 dpi
560 dpi
xhdpi
xxhdpi
As seen in Android Studio:
Although the Nexus 6 and 6P have different physical screen densities, the same drawable resource will be used for both devices.
About the Nexus 6, the manufacturer density is 560 but the physical density is about 493. Always think about the manufacturer density before think scale factor.
Related
On my Lg G stylo h634, it has a resolution of (720*1280) w/ a size of 5.7 inches and a real PPI of 258. With this information this phone should have:
DP width: 240
DP height: 240
Density: 1.5
Density PPI: 240
However when i run my test on this real device it's giving me:
DP width: 257
DP height: 258
Density: 2.0
Density PPI: 320
Now when i run an emulated version of my phone with the same specs, the first metrics are given (density: 1.5, PPI: 240, etc) which are the proper metrics. I'm not sure why this is happening, but can anybody explain why an emulated version is more accurate than the real device?
Its not always about the DPI and PPI. The real phone comes with variety of hardware components. although the specs of real phone and emulator is same but real phone renders things differently also it scale things differently. My advice is try to run you app. on few more physical devices and compare to emulator one of equivalent specs result would not differ much.
but can anybody explain why an emulated version is more accurate than the real device?
It's not. The device is what the device is.
On DisplayMetrics, xdpi and ydpi are the actual physical density values. For example, the documentation for xdpi has:
The exact physical pixels per inch of the screen in the X dimension.
In your question, you state that the device has "a real PPI of 258". That fits the values that you are getting from DisplayMetrics, bearing in mind that pixels are rarely square, so the xdpi and ydpi values are rarely exactly equal.
The value for density is based on a manufacturer setting (ro.sf.lcd_density in /system/build.prop, I think). Why LG decided to go with xhdpi instead of hdpi, I cannot say. If I had to guess, they felt that existing apps looked better on the device with that logical density. The emulator will use its own algorithm. Another manufacturer with a similar screen might choose hdpi (what the emulator chose).
The value for densityDpi is driven directly from density.
Are there xxxhdpi density devices?
Android devices screen density increases (see https://github.com/paulvi/displayclasses) and there are already devices with density higher than xxhdpi (extra-extra-high) ~480dpi
like Samsung Galaxy S6 577 2560 1440
(But I cannot check if it is really xxxhdpi)
Is it time to prepare 192x192 icons?
(4x times 48x48 dp, see http://developer.android.com/design/style/iconography.html )
See also Android Official Icons for XXHDPI and XXXHDPI
UPDATE: Was asked a year before as Android xxx-hdpi real devices
Also Nexus 6 and Nexus 9 Screen density
Just for reference purpose, now Google maintain a list of devices density and other information at https://design.google.com/devices/ which is mainly targeted for material design guideline.
Are there xxxhdpi density devices?
Afaik Nexus 6 is xxxhdpi device
New phones already use XXXHDPI.
Our test phone Samsung S6 Edge use xxxhdpi drawable resources. Someone already mentioned that Nexus 6 also using this dimension. Thus new phones with good screen should use this dimension.
xxxhdpi density devices Resolutions :
2048x1536
2560x1536
2560x1600
In Nexus 6
For more help :
http://developer.android.com/guide/practices/screens_support.html
Actually, no, even as of 2016, there are still no xxxhdpi device.
The largest resolution on Android device is used by Xperia Z5 Premium (4k on 5.5", or roughly 806ppi), and even on that device, it was only used that humongous screen density for multimedia contents. The UI itself was rendered by halving the effective density by two, so it actually scales down from 4k to full HD on 5.5", or xxhdpi.
Specs for Xperia Z5 Premium : http://www.gsmarena.com/sony_xperia_z5_premium-7536.php
I found 8 corresponding devices here.
My Samsung S22, released in February 25, 2022, has a 600 dpi when resolution is set to its highest (3088 x 1440), and more importantly, it loads xxhdpi resources, which means that we aren't there yet in terms of smartphones with 640 DPI or more screen density, and even if your phone contains 600 dpi like my S22 does, which is just 40 dpi shy off 640, it'll still load the 480 dpi (xxhdpi) resources.
I guess we'll get to 640 dpi in a year or two, I also expect the AOSP to add a xxxxhdpi to the source code very soon just as xxxhdpi was added in 2013, long before any 640 dpi handset was released.
what's the folder name for 1080p resource on android?
I know mdpi support 320x480
hdpi support 480x800
xhdpi support 720p
Unfortunately it isn't that easy. Mdpi, hdpi and xhdpi are all select based on screen density - basically the size of the pixels - not the number of pixels. So, if your 1080p screen is very large, it could conceivably be an mdpi screen (yes, it happens). You have the alternative to use small, normal, large and xlarge as selectors but these aren't tightly defined. A 1080p screen should be xlarge but so should a 720p.
The document at http://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources is useful.
This is a poorly worded question, but it seems like you are trying to support the new 1080 x 1920 phones coming out. The maximum pixel density that Android supports is 480 dpi, which is called xxhdpi.
A phone (3"-5" diagonal) at 1080 x 1920 will fall into the xxhdpi density, like the Samsung Galaxy S4 at 441 dpi. However, a tablet (7"+) at 1080 x 1920 will not be xxhdpi, so do not assume that density correlates to resolution.
You can clear about the Screen size, density pixels in android. I found tutorial Tips for designers and developers Android
I want the emulator to make use of the files present in the xhdpi folder and at the same time it should have low density. My emulator is set to a resolution of 1280 X 800 similar to motorola xoom tablet. Now if i keep a density of 149 ppi, android does not access the xhdpi folder. Please help. TIA.
Do not misunderstand Screen size, Screen density and Resolution. Read this article first.
hi guys i have been developing android app that should match most of the screen resolutions. And i just got struck at setting the drawable folder for this two resolution
1. 480 x 800 with approximate density of 217
2. 540 x 960 with approximate density of 240
And i have a different set of images for both the resolutions and i have set hdpi for 540 x 960 but don't have an idea of going about the 480x800 which also falls under hdpi. After goggling found a drawable qualifier called tvdpi which supports the appr. density of 213
When i set the tvdpi qualifier to the drawable folder i get "invalid resource directory name" error
Resolution and dpi are not directly related. It just so happens that many 800x480 devices are HDPI, then can just as easily be low dpi though if the screen is big enough.
If you really need direct resolution matching you will need to target API level 13 and use available width and height qualifiers for your resources or if you need to target a lower API level than 13, create your own resource loading scheme.
You can also use a combination of density and size qualifiers but that still leaves some room for two different resolutions falling into the same bucket.
But before you pick, you need to ask yourself do you really want the same pixel size for your drawables on a 3.7" 480x800 screen as you do for a 7" 480x800 screen.