The info I have found:
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).
But its coming from 2011. Now is 2014 and there are 2048x1536, 2560x1600, 1920x1200 tablets and phones. Are they still 720dp width or it does exist also 800dp, 1024dp or any other? That remains unclear to me because all the discussions I have found are from 2011 year, when there were no such devices on market.
If it depends on manufacturer, can you please share info about Sony Xperia tablet Z and Samsung TabPro 10.1 width in dp?
It also depends on density, not only on resolution.
Here are the equivalent for dp to pixels according to density :
mdpi : 1 dp = 1 pixel
hdpi : 1 dp = 1.5 pixel
xhdpi : 1 dp = 2 pixels
xxhdpi : 1 dp = 2.5 pixels
So, yes, a device with a resolution of 2560x1600 in xhdpi is 1530 dp wide.
Related
Hello there fellow programmers!
Currently I'm having problem with deciding size of an image in Android. I've read about it in Screen Support Guide but I'm still confused about dpi and screen sizes. I have a 140x150 image in 72 dpi. If I resize it to 160 dpi (mdpi) it'll turn into a huge image. I focused on smartphones only but now I'm considering tab. Should I have made a 160 dpi image with the same size of 140 x 150, or having a huge 160dpi image is normal?
Update 7th Jan :
Found an interesting plugin in Photoshop called Cut & Slice, going to try it now.
A pixel is just a square.
A dpi (dot per inch) corresponds to the resolution of the image.
The more pixels per inch, the sharper an image will appear because of the size of each pixel.
The conversion of dp units to screen pixels is simple: px = dp * (dpi / 160)
You should get two images with different size for different devices to improve the quality of your pictures and, when it's for webapps, the loading speed of your pages.
To help you target some of your designs for different types of devices, here are some numbers for typical screen widths:
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).
I am learning how to use "smallest width dp" to support different screens using this in android.
i get that below number are the smallest of side of device in dp.
Typical numbers for screen width dp are:
320: a phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc).
480: a tweener tablet like the Streak (480x800 mdpi).
600: a 7” tablet (600x1024).
720: a 10” tablet (720x1280, 800x1280, etc).
According to this post nexus 6 has 730 x 410 dp.
The Nexus 6 boasts an impressive 5.96” Quad HD screen display at a
resolution of 2560 x 1440 (493 ppi). This translates to ~ 730 x 410 dp
(density independent pixels).
but as explained in this
dp = (px/dpi)*160
= (1440/493)*160
= ~467
then how come this translates to 730 x 410 dp?
further more when i run the demo in nexus 6, device is using padding dimension defined under res/values-sw320dp/dimens.xml
this confuses me. how does one actually calculates dp and create view accordingly using "smallest width dp" ?
apart from res/values-sw320dp i have res/value and res/values-sw600dp that has dimens.xml under it.
UPDATE figured out my confusion. check comment under question.
You can get the correct values with the following code:
DisplayMetrics displayMetrics = this.getResources().getDisplayMetrics();
float dpHeight = displayMetrics.heightPixels / displayMetrics.density;
float dpWidth = displayMetrics.widthPixels / displayMetrics.density;
Log.d("dpHeight-----",String.valueOf(dpHeight));
Log.d("dpWidth------",String.valueOf(dpWidth));
For example for the Xperia Z 1080x1920px the values are 360x592dp, the settings is values-sw360dp
i just wanted to know. i've read about this DPIs and i wandered all of the varieties. since i am new to this, i need some knowledge and i hope someone can help me out. so far i've seen LDPI, MDPI, HDPI, XHDPI, XXHDPI, XXXHDPI.
is there any other DPI variety other than this. and what is their respective resolutions ?. like as for qHD = 960 x 540 etc etc. i hope you understand guys, thanks.
please forgive me if my grammar is a little crappy, as english is not my native language
Android supports different screen resolutions
ldpi (low) ~120dpi
mdpi (medium) ~160dpi
hdpi (high) ~240dpi
xhdpi (extra-high) ~320dpi
xxhdpi (extra-extra-high) ~480dpi
xxxhdpi (extra-extra-extra-high) ~640dpi
1 dpi = 1 design independent pixel
ldpi device have 120 pixels in 1 inch size.
same for other densities...
we as programmer should use this conversion formulae :
pixel = dp * (density / 160)
so 240 dpi hdpi device's 1 dp will have = 1 * (240/160) = 3/2 = 1.5 pixels
and 240 dpi xxhdpi device's 1 dp will have = 1 * (480/160) = 3 pixels
Using this 1.5 and 3 pixels knowledge, programmer can design layouts for different densities
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.
Actually i am new in android. I want to create an simple app that is able to run in all devices. The screen resolution i have selected for running my app are.
QVGA (240 x 320)
HVGA (320 x 480)
WVGA(800) (480 x 800)
WXGA720 (720 x 1280)
WXGA(800) (1280 x 800)
Now i am not able to determine the name of the resources folder for all these different resolution. I have through the documentation i.e support multiple screen but i not able to create resources folder for WXGA720 (720 x 1280) and WXGA(800) (1280 x 800).
So please anyone suggest me what are the resources folder i have to create for all these resolution.
To help you target some of your designs for different types of devices, here are some numbers for typical screen widths:
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).
For other cases in which you want to further customize your UI to differentiate between sizes such as 7” and 10” tablets, you can define additional smallest width layouts:
res/layout/main_activity.xml # For handsets (smaller than 600dp available width)
res/layout-sw600dp/main_activity.xml # For 7” tablets (600dp wide and bigger)
res/layout-sw720dp/main_activity.xml # For 10” tablets (720dp wide and bigger)
Remember to always define your layout meassurements in dp units. I have written a blog post to help you scale your layout xml-files proportionally so you only have to define them for a single "density bucket".
http://onemanmobile.blogspot.com/2012/04/how-to-scale-your-android-layouts-to.html
You usually create resource folders for the various density and size buckets, not for the specific resolutions. Normally applications only need a couple of different layouts (e.g: phone/tablet)