I can't wrap my head around the folders mdpi, hdpi, xhdpi and xxhdpi, are they meant for every kind of images or only for icons? The sizes in which my images are stored in there are really small, as you can see in this cheatsheet (click to enlarge):
xhdpi is 96px. In my app 96px looks really blurry (click to enlarge):
So how should I store my image then?
the folders mdpi hdpi xhdpi and xxhdpi, are they meant for every kind of images or only for icons?
Most bitmap drawable resources should get density-specific versions, at least for a few densities.
as you can see in this cheatsheet xhdpi is 96px
I see nothing in there saying that every image must be 96px for xhdpi. The standard action bar height and tab bar heights for xhdpi are 96px. That's it.
In my app 96px looks really blurry.
That image should have a higher resolution, as you are using it in a UI element that is far larger than the action bar or a tab bar.
So how should I store my image then?
Step #1: Determine your desired size for the image, in inches.
Step #2: Determine the resolution for the image in dp, by multiplying the size in inches from Step #1 by 160.
Step #3: Choose what densities you want to create specific artwork for. You might use the "Screen Sizes and Densities" section of the Android device dashboard to give you some ideas.
Step #4: Determine the density-specific resolution for the image in px, for the densities from Step #3, by multiplying the dp value from Step #2 by the size factor shown in the upper-left infographic of that cheatsheet.
Step #5: Create drawable directories for the densities from Step #3 and create your artwork in those, sized based on the values from Step #4.
Drawable folders are meant for all kind of images.
hdpi,mdpi,xhdpi,xxhdpi.xxhdpi are generally used to cover each and every device available in the market place.
nodpi folder is used to store images that can be used in any resolutions
For adding app icon try using the mipmap folders with all these above qualifiers for different size.
placing correct size images in correct folder will definitely work.
Related
I am wondering what would happen if you put for instance one image in only one specific size, let's say image X in hdpi and an other image Y in only resolution size xxhdpi, the size which was "right" for the device was xhdpi. Assuming that the OS decided what was the "right" size for the device.
Will it then downscale the image xxhdpi and upscale hdpi to xhdpi? Or would it only change the size of one image, for instance the one with the lowest resolution remains the same, the higher ones are downscaled?
Quite an interesting question out there!
In this case, the bigger drawable will be taken an downscaled to the device needs.
However, if the device is i.e. xxhdpi and you provide drawables ie. for mdpi and hdpi, the OS will take the hdpi drawable and scale it UP.
Android chooses the one appropriate for the resolution or screen dimensions. ..when it doesn't find one in the right folde than it goes down in the resolution searching for a lower quality folder...again when it doesn't find one in the folder with lower resolutions than it searches in the higher quality....and crashes if there is also none at runtime....AT compiletime you'll get error when thers n no image
Depends on how you display the images....Icons get everytime up or down scaled. ...IT is recommended that you have one and only one xxxhdpi icon in your app because downscaling is better than up scaling due to AA
so, I've created a project where I use an image in the action bar, but android only scaled it to the folders -mdpi, -hdpi, -xhdpi, -xxhdpi, why isn't it scaling to the low density folder ?
Btw, what if I want to use an image that is going to be the same size no matter what screen resolution is being used, should I create a folder just for this images ?
I believe they removed ldpi because there are so few ldpi devices out and they can make use of mdpi anyway.
Having an image the same size on any resolution is what these folders are for!! If you put an image in the static drawable folder its size will be different depending on what device you use because the pixel density is the same in the picture but it has to be scaled differently on screen to adjust for the larger or smaller density of the screen
go read the introductory android tutorials to learn more about screen density
This question already has answers here:
Android screen size HDPI, LDPI, MDPI [duplicate]
(4 answers)
Closed 9 years ago.
I have to manage different screen sizes and different densities in my Android app.
I am not getting directory structure properly.
What I understand so far is there are four types of screen sizes:
small
normal
large
xlarge
and different densities as well:
ldpi
mdpi
hdpi
xhdpi
Now each device size (small , normal , large and xlarge) shall map against each density. Because every size can have different density, right?
If yes, then we can say small screen have all the density i.e ( ldpi , mdpi , hdpi , xhdpi)
same for normal, large and xlarge.
The point is how I'll manage them in my drawable directories.
Will there be four folders for small screen size with different size (drawable-small-ldpi, drawable-small-mdpi, drawable-small-hdpi, drawable-small-xhdpi)?
And same for other screen sizes as well.
If not then how I'll manage all the image in ( drawable-ldpi , drawable-mdpi , drawable-hdpi , drawable-xhdpi) folder because different screen size I'll have different size of images. Then how can a small device with different density and large device with a different size be manageable in same density folder.
Please don't give me reference of any Android document as I read all that stuff.
If any one can't get my point, then please let me know. I'm very confused.
When I have started development in Android, I was confused about same issue.But now I have figured it out and I'm doing pretty well.
Anyways, You are absolutely right.you can provide different images by 4 folders for each.i.e.: drawable-small-ldpi, drawable-small-mdpi, drawable-small-hdpi, drawable-small-xhdpi
But it is just waste of your time.because you don't need to worry this much about it.Android can scale up/scale down according to the device configuration.so just provide extra images for those devices only if you don't get desired outputs for them.
As far as I know, supporting multiple devices, you have to consider few general criteria in your mind.
Density qualifiers: ldpi,mdpi,hdpi,xhdpi,etc are generally used when you want to provide different resolution images.
Size qualifiers + Orientation qualifiers: small,normal,large,xlarge,sw600dp,normal-land,normal-port,etc are generally used when you want to provide different layout designs.
i.e.: single pane layout,multi-pane layout,different elements in layouts according to different screen sizes.
For reference: Download the example app from here and try to understand how it is being supported for multiple screens.
I hope it will be helpful !!
Here are official docs for you to read about the subject: Supporting Multiple Screens then Supporting Different Screen Sizes
Put your all image in all different folder that is drawable-hdpi, drawable-ldpi, drawable-mdpi, drawable-xhdpi and drawable-xxhdpi. android will take care of it.
What I always do is just put all my images in one folder (usually xhdpi). The Android system will scale them for you so you don't have to worry about what to put in what folder.
Heres what Android says about this:
Provide different bitmap drawables for different screen densities
By
default, Android scales your bitmap drawables (.png, .jpg, and .gif
files) and Nine-Patch drawables (.9.png files) so that they render at
the appropriate physical size on each device. For example, if your
application provides bitmap drawables only for the baseline, medium
screen density (mdpi), then the system scales them up when on a
high-density screen, and scales them down when on a low-density
screen. This scaling can cause artifacts in the bitmaps. To ensure
your bitmaps look their best, you should include alternative versions
at different resolutions for different screen densities. The
configuration qualifiers you can use for density-specific resources
are ldpi (low), mdpi (medium), hdpi (high), and xhdpi (extra high).
For example, bitmaps for high-density screens should go in
drawable-hdpi/.
You can find the documentation here:
https://developer.android.com/guide/practices/screens_support.html
Hope this helps
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.
the more I read the Supporting Multiple Screens guide, the more I get confused.
if the layout folder's qualifier is based on size (small, normal, large and xlarge) and the drawable folder's qualifier is based on density (ldpi, mdpi,hdpi and xhdpi),
then how can I specify the size of the drawables/images??
should all the images inside the drawable folders have the same size (based on the normal screen size) but different densities (i.e. pic.png inside drawable.ldpi has the same width and height of pic.png inside drawable.mdpi but has different density)??
the problem is that each screen size may include the three densities (i.e. a large screen may be ldpi,mdpi or hdpi).
.how can I be designing the images on size basis and on density basis on the same time??
thank you.
36x36 for low-density
48x48 for medium-density
72x72 for high-density
96x96 for extra high-density
http://developer.android.com/guide/practices/ui_guidelines/icon_design.html
hope this helps.
In general you'll want the smallest pictures in ldpi, middle ones in mdpi, and larger in hdpi etc...
Even though it is technically possible for a device to have a "large" screen and an "ldpi" density manufactures have tended to stick to making devices with big screens be higher density as well.
EDIT:
The images only need to be designed with density in mind. Because if you take the same 100x100 pixel image and show it at 3 different densities it will appear largest (to human eyes) on the smallest density. So to account for that you make 3 images, lets say one 80x80, one 100x100, and one 120x120. Now if you show those 3 images across 3 densities the size that object appears to be to your eyes will be much closer than before.
the large, medium, small etc... qualifiers that you can add to the layout folders are not so much about any image resources themselves, but rather structuring the View components on the given page so as to make best use of the space available.
For instance, if your application has a list of items to choose from in it. On a tablet (large or xlarge) screen it may look nicer and be more effecient to have two or more columns of items displayed in your list on the screen. Whereas on a handset there may not be enough width (in portrait mode) to fit more than 1 column in. So to handle this situation you'd put a layout xml file inside the layout-normal folder that has a single column ListView. Then put another layout xml file in the layout-large folder that uses a GridView so that it can have an additional column
This image will show you roughly which folder the system will pull your images and/ or layout xml files from given the screen size and density.:
All of your image resources go in the drawable folders which are qualified with the densities. (ldpi, mdpi, hdpi etc)
The layout folders are what get qualified with the screen size (small, normal, large etc) The layout folders will contain xml layout files only, no images.