I am trying to emulate the size of a Galaxy Note screen, which is 1280 * 800 resolution and 285 ppi. But when i try to enter device configuration on Eclipse for Android, I have to enter xdpi and ydpi values (1280 * 800 ?), not ppi ones. I have the possibility to enter the density, but I only have the choice between : X-High Density, High Density, TV Density, Medium Density, and Low Density. I guess I have to choose X-High Density but how to be sure it is equal to 285 PPI ?
Do you know how to find the dpi informations to enter in order to have the same visualization ?
Thanks in advance !
You can compute the xdpi and ydpi
xdpi = 800/x-dimension of screen in inches
ydpi = 1280/y-dimension of screen in inches
I noticed that the device dimensions are about 3.3" x 5.8" so then (xdpi,ydpi)=(242,220)
From this, we can double check whether this results in the given ppi by sqrt(xdpi^2+ydpi^2) or 327 which is, unfortunately, quite far off of the given 285ppi (and I don't know why right now).
We can scale both xdpi/ydpi with 15% to (210, 190) which results in a ppi of 283.
But again, I would like to understand why this is needed.
But for your purpose, I guess that xdpi,ydpi=(210,190) would be a good match
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:
Screen resolution 1280 * 720 / xhdpi (Example: Sony Lt26i / Galaxy Nexus)
Which size of png/jpg for background(fill the whole screen without distortion) I shall use for the device (res/drawable-xhdpi), 1280px * 720px or 2560px * 1440px?
In this case, I always use 2560px * 1440px till I find some APPs use 1280px * 720px........
I believe double pixels shall be used on xhdpi screen.
Thanks a lot! ^_^
The exact size is: 1280x720 pixel.
When you hear about double pixels you are actually speaking about DIP, Density Independent Pixel.
A device which has a screen size of 1280x720 pixels, and has a XHDPI screen, will result in a 640x360 dp.
Android will take care of scaling and adapting the size for you, if needed.
Maybe it is a good idea to spend half an hour to read this:
http://developer.android.com/guide/topics/resources/providing-resources.html
According to this guide's chapter px = dp * (dpi / 160) and to that layout specifications change from buckets(physical size in inches) to "dp" units so that:
320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800
hdpi, etc).
480dp: a tweener tablet like the Streak (480x800 mdpi).
600dp: a 7” tablet (600x1024 mdpi).
720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).
Since "dp" values depend on "px" and "dpi" values so that: dp = px / (dpi / 160) - isn't it possible that a phone device with high resolution will take a layout from w600dp folder?
For instance: Samsung galaxy s3 dp = 1280 / (303 / 160) = 670; Samsung galaxy s2 dp = 800 / (217 / 160) = 592. So, galaxy s3 is going to take "tablet-oriented" template, right. Is it okay, especially if a tablet version contains more elements and overall interface ergonomics gonna suffer from the tablet layout in case of s3 ? Why don't just stick to display buckets ?
You're probably going to recommend using "sw" key but I just want make sure that those "dp" units actually relate to sizes so that tablet-oriented template won't be shown on phone devices.
So, would you mind sharing your practical knowledge on applying the new approach ?
Thanks
A dp or dip is a (screen) Density Independant Pixel. The confusing part about that is that is mentions pixel. It is actually a unit similar to a centimeter or inch.
Each device defines a dpi bucket for it's screen, for example mdpi which is 160dpi. That means that you find 160 pixel across one inch on the screen. It's not 100% accurate since physical screens are usually not exactly 160 dpi (or whatever value that is defined for the bucket). But it's a value that comes close.
That means that 160dp on a perfect 160dpi screen are actually 160 pixel. On a device with a perfect xhdpi (=320dpi) screen those 160dp would be 320 pixel. (px = 160dp * (320dpi / 160))
To work with dp don't think in pixel. Think in inch, milimeter or what unit you prefer. The recommended 48dp rythm for UI elements for example explains that
On average, 48dp translate to a physical size of about 9mm (with some variability)
To approximate that: 50dp = one finger wide.
That hopefully explains why a typical 320dp phone screen is always smaller than a 720dp tablet screen although the smaller screen can have more pixel than the larger. The dpi / pixel thing is already factored into dp.
How to do different layout for different screensizes? (i.e. phone vs table)
Use the screen size buckets (small, ..., xlarge) for the layout. They represent physical small to large screens. You don't need sw600dp etc unless you need to adjust very special cases.
The different dpi buckets should only concern you for images. E.g. high resolution images for high resolution screens of any size in the drawable-hdpi folder.
The S3 does not have a density of 160.
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).'
I did my analysis and found that most of the users of my application will be of samsung galaxy S2, and samsung galaxy note . Doing research on their technical spec, I found:
Galaxy S2:
480 x 800 pixels, 4.3' display
Galaxy Note:
1280 x 800, 5.3”screen
How can I categorize these into Layout size and desnity level? I think I can figure out the layout size as mentioned in the android development page
However I am unable to know the density level (low, medium high xhigh). They say that I need the dpi but in functional spec, I rarely see the dpi, I just see the above resolution
Thank you
Calculate the density first Density=Square root((wp*wp)+(hp*hp))/di
where wp is width resolution in pixels, hp is height resolution in pixels and di is diagonal size in inches. It would come ~208 for S2.
ldpi ~120dpi,mdpi ~160dpi, hdpi~240dpi, xhdpi ~320dpi. Compare from these values of dpi
Not sure if I understand you correctly but you can request the density level and the dpi from the DisplayMetrics class. Using resolution and density you can approximate the display's size.
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);