How do I know how much DPIs a device has (and thus if it's ldpi / mdpi / hdpi / xhdpi, - and screen size, which is also measured in dp - xlarge / large / normal / small - according to http://developer.android.com/guide/practices/screens_support.html)?
I know the device's resolution and diagonal size, for example:
Display TFT LCD, 3.5 in (89 mm) diagonal.
320×480 px HVGA with Gorilla Glass
16M colors
(Taken from http://en.wikipedia.org/wiki/Samsung_Galaxy_Ace)
Don't need it programmatically, just to calculate myself.
Use DPI calculator to calculate dpis, and Figure 1 in the dev docs to determine whether its ldpi, mdpi, etc.
I think DPI reffers to printers... IN your case DPI = PPI. Please correct me if i'm wrong [edit: I'm wrong :P]
'So a 1200 dpi printer uses 1200 dots of ink in every inch to make up the colours. If you were printing a 300 PPI image, then every pixel would be made up of 16 smaller ink dots (1200 DPI x 1200 DPI / 300 PPI x 300 PPI). A lower DPI would have fewer ink dots making up each pixel, which would make the colour look worse. A higher DPI would have more ink dots for each pixel and should give more accurate colour (especially under close examination).'
Related
I want to know the screen size of an Android phone (without using code)
For example: I find that from specs someone has a device with 1080 x 1920 pixels (~445 ppi pixel density)
How would I go from here to figure out which layout his or her phone will support?
From this document, I got:
lpdi = 120 DPI
mdpi = 160 DPI
hdpi = 240 DPI
xhdpi = 320 DPI
xxhdpi = 480 DPI
xxxhdpi = 640 DPI
And this rough estimation below which seems so ridiculous.
Where does the DPI fall, if it is 215 for example?
I want to know the layout size to choose for a particular device that I don't own:
Whether the layout be should be small, medium, large, or extra large ?
There's a bit of confusion between dpi and ppi.
The correct term should be ppi, but it's dpi by convention.
So, roughly, we can assume that ppi = dpi, for our purposes.
For your reference: http://www.fastcodesign.com/3039564/the-difference-between-ppi-vs-dpi-explained-by-a-google-designer
445 ppi falls in the 480 dpi normalized bucket. 215 ppi falls in the 240 dpi normalized bucket.
I used the term "bucket" improperly: I should have said "range", to be more clear.
How would I calculate the ranges?
I'd say that the range starts from the median between (320 and 480) + 1 and ends at the median between 480 and 640.
Therefore, for the 480 "bucket", I calculate a range between 401 and 560. And 445 falls here into.
Note: it's all empyrical.
The proposed figure on the Android developers site is a poor representation of the concept.
I prefer to imagine those buckets like adjacent funnels with a "mouth" which is 160 dpi wide and an end which points to a normalized value.
Here's an image I prepared just to make it even more clear:
I am a visual designer, working on an android design and I"m trying to spec my PSD file for our engineers. I cannot seem to find any documentation regarding the conversion of point size to SP for the type in any Android documentation. (Just that SP should be used for type).
The problem is that it depends on the density. Really, they're not good measurements to try to compare.
Points: There are 12 points in a pica, 6 picas per inch, so 72 (more accurately 72.27) points per inch.
Device-Independent Pixels (DP): These will be equal to the pixel size for MDPI displays, 1.5x the pixel size for HDPI displays, and 2x the pixel size for XHDPI displays. (e.g. 12dp = 12px MDPI, 18px HDPI, 24px XHDPI).
Scaled Pixels: These will be equivalent to the DP value, but scaled according to the user preference to be smaller or larger.
If you're designing at 72 dpi (Photoshop default DPI setting), an 8pt font would be equivalent to 8px, which would be 8px at MDPI, 12px at HDPI, and 16px at XHDPI, or more simply 8dp for all densities. I don't know how much scaling gets applied to different SP settings, so you'd have to hunt that out, but basically I would just give them the mockup and let them size it appropriately from there -- surely they can get it pretty close visually from that.
In contrast to dp (and sp with minus the user text sizing factor), pt has pretty much the exact same physical measurement. Dp is more or less a rough approximation, since it uses the same factor for a wide dpi range.
You cannot convert pt to sp, like said by Flavio. You can, however convert pt to dp roughly (+/- 30% in extreme cases, but at least expect +/-10%).
Using the dpi buckets (ldp=120,mdpi=160,hdpi=240,xhdpi=320) the most generic conversion factor would be x0.45 (= 72/120*0.75 = 72/160*1 = 72/240*1,5 = 72/320*2) if using the exact dpi bucket values.
For more precise factors:
mdpi (scaling factor: 1.0) 10.1" WXGA Screen (149dpi) is 0.483076923 (= 72/149 * 1.0)
hdpi (scaling factor: 1.5) Nexus 7 (216dpi) is 0.5 (= 72/216 * 1.5)
xhdpi (scaling factor: 2.0) Nexus 10 (300dpi) is 0.48 (= 72/300 * 2)
So 12 pt would be on...
10.1" WXGA: 24.84dp
Nexus 7: 24 dp
Nexus 10: 25dp
dpi bucket value: 26.666dp
You could use the same values for sp, but keep in mind, that these could be in/decreased by the users settings.
There's no direct mapping between pixels and sp, since sps are dynamically set as the users change the device font size in system settings. The user may want to see all the app fonts in smaller or larger sizes. It's an accessibility feature provided by the OS.
^What Flavio said. but check out the display metrics class overview on the Android Developers site. You might find what you need here... http://developer.android.com/reference/android/util/DisplayMetrics.html#
This is a great tool to help convert between the various measurements - put in what you know and it'll calculate the rest!
http://angrytools.com/android/pixelcalc/
There are 72 pts per inch, and 160 sp per inch (with standard font size in the device settings). this means there are 160sp per 72pts. 160sp/72pts simplifies to 20/9. So when converting pts to sp or dp use pts*20/9. As mentioned by others here already, sp does vary by the user's settings so if you don't want the text size to change with the device settings, then use dp.
I am a visual designer, working on an android design and I"m trying to spec my PSD file for our engineers. I cannot seem to find any documentation regarding the conversion of point size to SP for the type in any Android documentation. (Just that SP should be used for type).
The problem is that it depends on the density. Really, they're not good measurements to try to compare.
Points: There are 12 points in a pica, 6 picas per inch, so 72 (more accurately 72.27) points per inch.
Device-Independent Pixels (DP): These will be equal to the pixel size for MDPI displays, 1.5x the pixel size for HDPI displays, and 2x the pixel size for XHDPI displays. (e.g. 12dp = 12px MDPI, 18px HDPI, 24px XHDPI).
Scaled Pixels: These will be equivalent to the DP value, but scaled according to the user preference to be smaller or larger.
If you're designing at 72 dpi (Photoshop default DPI setting), an 8pt font would be equivalent to 8px, which would be 8px at MDPI, 12px at HDPI, and 16px at XHDPI, or more simply 8dp for all densities. I don't know how much scaling gets applied to different SP settings, so you'd have to hunt that out, but basically I would just give them the mockup and let them size it appropriately from there -- surely they can get it pretty close visually from that.
In contrast to dp (and sp with minus the user text sizing factor), pt has pretty much the exact same physical measurement. Dp is more or less a rough approximation, since it uses the same factor for a wide dpi range.
You cannot convert pt to sp, like said by Flavio. You can, however convert pt to dp roughly (+/- 30% in extreme cases, but at least expect +/-10%).
Using the dpi buckets (ldp=120,mdpi=160,hdpi=240,xhdpi=320) the most generic conversion factor would be x0.45 (= 72/120*0.75 = 72/160*1 = 72/240*1,5 = 72/320*2) if using the exact dpi bucket values.
For more precise factors:
mdpi (scaling factor: 1.0) 10.1" WXGA Screen (149dpi) is 0.483076923 (= 72/149 * 1.0)
hdpi (scaling factor: 1.5) Nexus 7 (216dpi) is 0.5 (= 72/216 * 1.5)
xhdpi (scaling factor: 2.0) Nexus 10 (300dpi) is 0.48 (= 72/300 * 2)
So 12 pt would be on...
10.1" WXGA: 24.84dp
Nexus 7: 24 dp
Nexus 10: 25dp
dpi bucket value: 26.666dp
You could use the same values for sp, but keep in mind, that these could be in/decreased by the users settings.
There's no direct mapping between pixels and sp, since sps are dynamically set as the users change the device font size in system settings. The user may want to see all the app fonts in smaller or larger sizes. It's an accessibility feature provided by the OS.
^What Flavio said. but check out the display metrics class overview on the Android Developers site. You might find what you need here... http://developer.android.com/reference/android/util/DisplayMetrics.html#
This is a great tool to help convert between the various measurements - put in what you know and it'll calculate the rest!
http://angrytools.com/android/pixelcalc/
There are 72 pts per inch, and 160 sp per inch (with standard font size in the device settings). this means there are 160sp per 72pts. 160sp/72pts simplifies to 20/9. So when converting pts to sp or dp use pts*20/9. As mentioned by others here already, sp does vary by the user's settings so if you don't want the text size to change with the device settings, then use dp.
If I have an image 240 by 240 pixels designed in Adobe Illustrator (for example) at 240 dots per inch for high density screens, what would be the best way to save a version of this image for medium density screens? Should I keep the image at 240 by 240 pixels and reduce the dots per inch to 160? Or keep the image at 240 dots per inch and shrink it to 160 by 160 pixels? Or some other variation?!
AFAIK DPI is ignored, it's only relevant for printing where it tells the printer how many pixels to print per inch, there is always exactly one screen pixel per bitmap pixel*, so as the other comment suggests, you just need to scale the image using the ratios 3:4:6:8.
*Essentially, anyway.
So I create sets of assets for an Android UI - 320 x 400 & 480 x 800 both of these at 160 and 240 dpi...
After Drawing some of the assets as 9 patch a weird thing happened. The 9 patch graphics all 'came out' as 72 dpi but with different dimensions!
So my conclusion is that android asset creation works similiar to iPhone. Creatings assets to dimensions and ignore DPI (using 72 as a base - as this is what the 9 patch programme converted them too!) RIGHT?
Anyone else experimented with this?
Just think for a minute about what DPI is. Dots per Inch. For displays, it's actually Pixels per Inch, or PPI.
A 320 pixel wide image at 160 pixels per inch is 320 pixels wide. How many pixels wide is a 320 pixel image at 240 pixels? The PPI density only matters on the actual output device. Your display has a fixed number of pixels at a fixed physical size. The number of pixels that fit into 1 inch is its PPI density. The reason this is modifiable for graphics is for when the density can differ. Most commonly, this is for printing (which is where the dots come in). Most printers can print at a variety of resolutions. The typical is something like 300 dpi for images, 1200 dpi or higher for vector graphics and line art. When you set the dpi before printing an image, it tells the printer how many dots per inch it should lay out. The higher the dpi, the sharper the image -- assuming the input image is actually large enough to accomodate this resolution.