I've come across with this table showing what Android uses as baseline for screen density:
Here i understand that if my mdpi image is 100px, then i have to use 150px(1.5 factor) for hdpi.
Question 1: Does mdpi targets screen densities between 120dpi screen and 160dpi screen? Because my phone has 432dpi(or ppi) and it uses xxhdpi, so i thought xxhdpi targets screen densities between 320dpi and 480dpi, right?
But here i've came across with different table, showing example:
Question 2: According to assumption above, xhdpi should target between 240dpi-320dpi, but in second table 336dpi is also considered as xhdpi, why? And what happens if user has screen density > 480dpi and i don't have xxxhdpi folder?
Android picks the right density bucket for a given DPI value based on the bucket which has the least difference in DPI value.This can easily be seen in de following image:
Quote:
Figure 1. Illustration of how Android roughly maps actual sizes and densities to generalized sizes and densities (figures are not exact).
Source: http://developer.android.com/guide/practices/screens_support.html#range
Question 1:
Mdpi targets roughly anything between 140 DPI and 180 DPI.
Question 2: 336 DPI is considered xhdpi because the xhdpi bucket is the closest one (in DPI value: 6). The difference to the hdpi bucket is 96 and the difference to the xxhdpi bucket is 144.
When a density folder is missing Android picks the best alternative folder and if needed applies scaling to the resources to match the target density.
Related
What is the best way to find the best layout qualifiers for a specific Android device?
There are no resource qualifiers that are device-specific. For example, you can't specify layout-neuxs-5.
This is because you rarely want to change a layout for one specific device when there are likely dozens of other similar devices that need a similar layout (or other set of resources).
The first step then is identifying what exactly defines the type of device that needs a different resource. You can provide different resources of any type (layout, drawable, string, etc.) for any sort of qualifier you can imagine- language, screen orientation, screen size, screen density, and more.
While you didn't provide any specifics, I'm going to assume that you are looking to provide different layouts for differently sized screens. For this, you generally want to use the smallest-width qualifier (e.g. layout-sw320dp, layout-sw720dp).
If that's the case, then the real question you are asking is likely more along the lines of "how do I know what size screen a device has?" To calculate that, you need to know two things:
The device's density class (mdpi, xhdpi, etc., which you can calculate based on the physical screen size and resolution)
The device's resolution
Let's look at the Nexus 5. It is and xxhdpi device and its resolution is 1080 x 1920 pixels. xxhdpi is a 3x scale, and the smallest dimension is 1080, thus 1080 divided by 3 = 360dp. The smallest width of a Nexus 5 is 360dp.
Thus to provide resources that are at least the approximate size of a Nexus 5, you would put those resources in a folder with the -sw360dp qualifier.
Here are some common sizes suggested by the documentation:
320, for devices with screen configurations such as:
240x320 ldpi (QVGA handset)
320x480 mdpi (handset)
480x800 hdpi (high-density handset)
480, for screens such as 480x800 mdpi (tablet/handset).
600, for screens such as 600x1024 mdpi (7" tablet).
720, for screens such as 720x1280 mdpi (10" tablet).
You could use this kind of application:
https://play.google.com/store/apps/details?id=com.sturnus.screeninfo
https://play.google.com/store/apps/details?id=lt.andro.screensize
To retrieve density, screen size, ...
Yesterday I already asked a question about this here. After that I saw this on the official android developer page:
So you can have a 1024x600px screen device with ldpi and a screen with the same resolution with mdpi.
Furthermore you can have a 600x1024px screen device with mdpi and a screen with the same resolution with hdpi.
I have an image, that takes 20 % of the screen's height and width on every device.
I want to make 5 versions of that image (with different resolution) for each drawable folder.
In my past thread I got this answer:
ldpi: 0.75
mdpi: 1.0
hdpi: 1.5
xhdpi: 2.0
xxhdpi: 3.0
xxxhdpi: 4.0
These are the scale factors.
So if my image has a resolution of 50 x 100 px in mdpi it is supposed to have a resolution of 75 x 150 px in hdpi.
I understand that.
The question now is, how am I supposed to know what resolution my image should have in the mdpi folder, if the resolutions for mdpi are totally different (as you can see in the image above -> from 320x480 to 1280x768).
Thanks !
The drawables should be created at a resolution that makes them the right physical size when displayed on the screen. If you have an icon that is supposed to be 1/2 inch by 1/2 inch on an MDPI screen, then the image should be 80px by 80px. This size should be irregardless of the physical dimensions of the screen; the same drawable on a 1280x768 MDPI tablet is supposed to be 1/2 inch by 1/2inch.
If the icon in question should be larger on the tablet for some reason, then you would need to introduce the drawable-swXYZdp-mdpi folder that Der Golem mentioned above. In this folder, you would be able to create a version of the icon that had a larger physical size (say 3/4 inch) that will be loaded on the tablet.
I Need to create a Designs for a Andriod Application.
I can see everyone are speaking about this "ldpi,mdpi,hdpi & xhdpi....etc.," My biggest doubt is in WHAT RESOLUTIONS, I should create the designs in Photoshop?? As there are lots of screen sizes available now. WHAT DEFAULT SCREEN SIZES I SHOULD DESIGN WITH FOR EACH "ldpi,mdpi,hdpi & xhdpi ?" Like for Xhdpi - What Screen resolution Should I do ?
a. 720x1280 - 320 dpi
b. 2048x1536 - 320 dpi
c. 2560x1536 - 320 dpi
d. 2560x1600 - 320 dpi
Again the same resolutions for ldpi,mdpi and hdpi ? What Screen Resolutions for the respective DPI's
Which Screen Resolutions for
a. 120 dpi ?
b. 160 dpi ?
c. 240 dpi ?
PLEASE CLARIFY ME GUYS.
THANKS A TON IN ADVANCE
See this calculator.
ldpi is 120 dpi
mdpi is 160 dpi
hdpi is 240 dpi
xhdpi is 320 dpi
xxhdpi is 480 dpi
xxxhdpi is 640 dpi
(Thanks to Tobor for adding those last two and correcting my typo, I accidentally overwrote his edit)
Also, I don't know why Maneti's initial advice was downvoted. When in doubt, use this tool (or the one in your android sdk) to generate your icons, then import those icons you generated into Photoshop. That's actually the most pragmatic and easiest solution (that doesn't require any thinking on your part and yet that solution works all the time for densities).
As to the size of an image (as defined by the Android guidelines/terminology), only worry about the size of that image if it's a image that could potentially take the entire width, or the entire height, of the screen (like a large background image for instance).
So in most cases, most developers end up not needing the size qualifier for their drawables (because it won't make a difference unless it's a large background image).
For 120, 160, 240 dpi, respectively, I'm condidering 240*320, 320*480 and 480*800 (or 854) screen sizes.
For xhdpi (320) I'm considering 1280*720 (or 800).
But this is only a reference
Take in account that your design should scale
So, the graphical elements should stretch or be repositioned well.
After all, the screen size is not so important, if you project your objects positions and sizes well.
Use dp for objects and sp for font sizes, use the proper dpi resolutions for graphics and you shold be fine.
You can't follow any existing resolution. Generalize.
You could start with with XXHDPI and then export your assets from there. I found that 1080px x 1920px and 72ppi is a comfortable size to design in Photoshop and allows you to export to other resolutions by downscaling (you should avoid scaling assets up). You can then you use this Photoshop script I wrote or Cut&Slice me to export assets from that document to the other resolutions (XHDPI, HDPI, MDPI, and LDPI).
I would also recommend using a Sprite Sheet PSD for your assets to keep things clean and organized.
Hope this helps.
first I think you meant ppi not dpi.
second since the graphics are intended to be used on screen only the size in pixels matters. The ppi could be what ever you want.
ppi (pixels per inch)/dpi (dots per inch) is used to measure the resolution of the output in the real world.
So why people use ppi if it doesn't matter?
Some people like to use the ppi when sizing the files for proportions. This way you can change the ppi number and get the proportions right.
let's assume you start with xxhdpi with a ppi of 480.
Then if you change to 320 you will get xhdpi
240 > hdpi
160 > mdpi
120 > ldpi
but you can use percentages as well.
I am working on a Android Project.
I put the images (320*480) into the mdpi -folder. There are some information in Android developer site that 480*800 tablets(7") also takes images from the mdpi- folder. When the 7" tablet takes images form that mdpi- folder it become smaller. There is only one mdpi- folder so how do i exactly manage it .
You should read the Android developer documentation on Providing Alternative Resources.
From my answer to this similar question:
The ImageView will render the image inside of it at the correct resolution for the device. As per the documentation on providing resources, you must make sure that you provide resources at the correct DPI for each of the resolution types. Android will pick the best resource resolution for you, but if only one resource exists then it will pick that one and try to render at the device resolution.
So, find out the correct DPI for your device, and add the image (at the correct DPI) into that folder and it should appear at the correct size. If the image is placed in the wrong folder then it will appear a different size. Another useful link is the Density Independence documentation.
Note: let's assume your device is an HDPI device. The res/drawables/drawable-hdpi folder might not exit in your project but you can just add it in manually.
Don't mix up screen size with screen density. There are qualifiers related to screen size (e.g. small, normal, large, ...) and qualifiers related to density (e.g. ldpi, mdpi, ...).
You can even combine these qualifiers, for example in drawable-normal-mdpi you can put resources that will be used on devices with normal screen (phones) with a mdpi density.
you should create ldpi, hdpi, xhpi folder too. And you need to copy your image with same name by calculating its ratio.
ldpi - mdpi - hdpi - xhdpi
3 4 6 8
There is a 3:4:6:8 scaling ratio between the four primary densities
(ignoring the tvdpi density). So, a 9x9 bitmap in ldpi is 12x12 in
mdpi, 18x18 in hdpi and 24x24 in xhdpi.
If you decide that your image resources don't look good enough on a
television or other certain devices and want to try tvdpi resources,
the scaling factor is 1.33*mdpi. For example, a 100px x 100px image
for mdpi screens should be 133px x 133px for tvdpi.
I've read 10 articles yet still cant find any relation between ldpi, mdpi, hdpi and the actual dimensions in pixels!? Can anybody give a straightforward answer please(if there is one!)
I'm basically trying to put together a splash screen that needs to work on multiple devices without stretching - but i'm struggling as everything I try is either squashed or stretched!?
Cheers
Paul
The ldpi, mdpi and hdpi refer to screen density, which means how much pixels can fit into a single inch.
the ratio in pixels between them is:
ldpi = 1:0.75
mdpi = 1:1
hdpi = 1:1.5
xhdpi = 1:2
xxhdpi = 1:3
xxxhdpi = 1:4
so lets take an image with about the size of 100X100:
for mdpi it should be 100X100
for ldpi it should be 75X75
for hdpi it should be 150X150
for xhdpi it should be 200X200
for xxhdpi it should be 300X300
for xxxhdpi it should be 400X400
this way, for screens with the same size but different DPI, all the images seem the same size on screen.
Also you have multiple screen size types small, normal, large, xlarge and each one of them can be ldpi, mdpi, hdpi, xhdpi, xxhdpi (Nexus 10) or xxxhdpi.
You can try to create a splash screen image that fit to each and every screen type
which gives you 4*5 = 20 different images (it seems to much for me).
For now only the Nexus 10 is at the xxhdpi category.
Install ImageMagick and use this shell script to generate your splash and icon files for multiple devices - iOS, Android, Bada and Windows Phone. You can use cygwin/gitbash if you are on Windows
I just did and I'm pretty happy with it :-)
The screen sizes are inside the script and are -
480x800 - screen-hdpi-portrait.png
320x200 - screen-ldpi-landscape.png
720x1280 - screen-xhdpi-portrait.png
320x480 - screen-mdpi-portrait.png
480x320 - screen-mdpi-landscape.png
200x320 - screen-ldpi-portrait.png
800x480 - screen-hdpi-landscape.png
The definitions are:
xlarge screens are at least 960dp x 720dp. large screens are at
least 640dp x 480dp. normal screens are at least 470dp x 320dp.
small screens are at least 426dp x 320dp. (Android does not currently
support screens smaller than this.)
Also, check out this blogpost from Dianne Hackborne:
http://android-developers.blogspot.com/2011/07/new-tools-for-managing-screen-sizes.html
Probably the easiest thing is to use an image view and set the scaletype to CENTER_CROP.
(Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or larger than the corresponding dimension of the view).
Make sure that you use the src tag rather than setting the background.
<ImageView
android:id="#+id/home_video_layout"
android:src="#drawable/splash_image"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
/>
Updated:
Understanding Screen Densities and the “dp”
Resolution is the actual number of pixels available in the display, density is how many pixels appear within a constant area of the display, and size is the amount of physical space available for displaying your interface. These are interrelated: increase the resolution and density together, and size stays about the same. This is why the 320x480 screen on a G1 and 480x800 screen on a Droid are both the same screen size: the 480x800 screen has more pixels, but it is also higher density.
To remove the size/density calculations from the picture, the Android framework works wherever possible in terms of "dp" units, which are corrected for density. In medium-density ("mdpi") screens, which correspond to the original Android phones, physical pixels are identical to dp's; the devices’ dimensions are 320x480 in either scale. A more recent phone might have physical-pixel dimensions of 480x800 but be a high-density device. The conversion factor from hdpi to mdpi in this case is 1.5, so for a developer's purposes, the device is 320x533 in dp's.
I have found this online dip <--> pixels calculator very useful.
https://pixplicity.com/dp-px-converter/
I support previous answers but don't forget the power of Draw9Patch or using NinePatchDrawables
These refer to screen pixel density, not screen dimension. You need to look into screen size specifiers like small, medium, large, and xlarge instead if you really need to change behavior based on screen size in pixels.
The Android docs explain what densities and sizes match these identifiers.
Android devices can have different width-to-height ratios, while your image has a fixed one. If you do not want your image stretched, you will have to fill the blank spaces above and below or left and right.