In my application I have to use hundreds of bitmap icons and we want to support multiple screen.
And through the documents at android developer, it seems that it is the only way to create these icons for different devices with different dpi.
If this is true, we will have a hard work, so I want to know if there is an alternative to avoid this?
Given the number of icons that you're dealing with, creating multiple versions of each manually is clearly out of the question.
I suggest that you create your icons at the xhdpi resolution, and come up with an automated process (perhaps using something like ImageMagick, and the scripting language of your choice) to produce the lower resolutions as part of your build process.
You don't have to provide different bitmap resources for all possible pixel densities, but ideally you would provide low dpi (ldpi), medium dpi (mdpi), high dpi (hdpi) and extra-high dpi (xhdpi) icon resources.
If you don't provide all of the above, the Android system will automatically pick the closest matching resource and scale it to match the actual screen pixel density.
Please visit Android Asset Studio wherein this site will provide all types of dp icon images of your requirement.
In your case, go for Generic icons section or Menu icons section.
Hope this helps.
You can put your images in /res/drawable, then Android would scale them according to dpi in order to keep the image to be roughly the same physical size regardless of display density. In this case an image would be unmodified in MDPI, 1.5x larger in HDPI, 2x larger in XHDPI, and 3x larger in XXHDPI.
You can also put them in /res/drawable-nodpi, in which case no image rescaling would be applied, but it is hardly ideal as the same image would be physically 3x smaller in XXHDPI than in MDPI.
All of the above methods have serious cons, so really the most sensible method is to put the correct sized images in their respective DPI folders. Your images should be drawn in a much larger resolution, so it should just be a matter of rescaling each image to different DPI sizes.
Related
hey everyone
I've been facing drawables and layout related issues for a few days....
there are drawable-ldpi, drawable-mdpi, drawable-hdpi, drawable-xhdpi and drawable-xxhpdi folders in resources directory in android project
I've gone through the official android doc several times it definitely explains everything pretty welle.g scaling ratios for ldpi(0.75), mdpi(1), hdpi(1.5), xhdpi(2)but i couldn't find any information regarding which resolution to start with???
for example if i start designing graphics resources for xhdpi folder then which resolution i should go for???as there are many devices out there which lie in extra high density bucket but each having different resolutions, for example
Nexus4 (768x1280 xhdpi)
Nexus 10 (2560x1600 xhdpi)
Galaxy Nexus (720x1280 xhdpi)
same is the case with hdpi and mdpi bucket, lots of devices are there then which resolution images we should place in the corresponding folder????
please guide me guys m really in trouble
Look at #CommonsWare's answer.
I add that we are talking of dpi.
MDPI (160dpi)
HDPI (240dpi)
XHDPI (320dpi)
XXHDPI (480dpi)
XXXHDPI (640dpi)
Then:
to convert between dp and pixels use this formula:
px = dp × density ÷ 160
but i couldn't find any information regarding which resolution to start with?
For the vast majority of apps, if you are worrying about resolution, you are doing it wrong.
Ask yourself how you would write this as a Web app. Browser windows can have an arbitrary number of pixels of width and height, because the user can resize those windows as she sees fit. You are not going to design distinct imagery for a 1023x805 window instead of a 1037x740 window. Instead, you are going to take some approach that can handle a reasonable range of window sizes, perhaps with alternative artwork when you jump to a new range of window sizes.
Then, take that design approach, and apply it to your Android app. Focus on screen size and density, not resolution.
which resolution images we should place in the corresponding folder?
Resolution has nothing to do with density.
dpi has nothing to do with resolution. The dpi system is made so that a certain image will be (about) the same physical size no matter of the screen density, for example Google suggests that Buttons should be 48dp which is (about) 9mm on ANY density, but resolutions are different on any device, and including tablets you can't really worry about resolutions.
When making an app think about how you want to look, not in exact manners, for example "I want this line to have four buttons", make a LinearLayout with four buttons and you are done! (Sometimes you may want to include a horizontalScrollView depending on the size of the buttons).
Over time you will manage to understand this better, it's a matter of practise!
I was wondering, why are we using different launcher icons (sizes) in android. Currently you "have" to resize your icon to:
LDPI - 36 x 36
MDPI - 48 x 48
HDPI - 72 x 72
XHDPI - 96 x 96
And put them in the desired folder. But does it really matter if you would only put a xhdpi icon in your android application, and if you just leave the ldpi, mdpi and hdpi folder empty.
If you try the app with this configuration (only a xhdpi icon) on a mdpi device, automatically the xhdpi icon is used (I assume the device scales the icon automatically), and it looks just normal.
So what would stop us from only making a xhdpi icon. It will still result in a sharp app icon for every device (except xxhdpi ofcourse).
Rescaling overhead. Your icons may be used not only by your app, but also by few others. Like launchers, setting apps for installed software, share menus in many places.
Note that the higher the resolution, the more powerful the hardware. The lower the resolution, the less powerful the hardware. You may take an easy exercise. Open up an image in Gimp with resolution of 3000x3000. Scale it down to 50%. Even on a high end desktop it will take some time. Not long, but will.
As described here in the documentation provided by android it is better to use different variants of drawables mainly because of the following reasons.
Rescaling is an overhead for the mobile device's processor.
You will not get the perfect image when using on different phones because it will get pixelated or blurred.
You will have to handle the image sizes to fit in the layouts to give the same look and feel on all the screens.
Also creating one icon for xhdpi and using it for hdpi, mdpi and ldpi won't create sharp looking images. It will create drawables where pixels are overlapped on each other, giving the feel of a sharper image in hdpi but might not be viewable on either an mdpi or for sure on an ldpi screen.
Down scaling the images is as deteriorating in terms of quality as is up scaling.
So it is always better to have different launcher icons for different screens!
Although the system performs scaling and re-sizing to make your application work on different screens, you should make the effort to optimize your application for different screen sizes and densities. In doing so, you maximize the user experience for all devices and your users believe that your application was actually designed for their devices—rather than simply stretched to fit the screen on their devices.
This following five factor decide which assets is convenient to your device
Screen size
Screen density
Orientation
Resolution
Density-independent pixel (dp)
there are 2 main reasons that i can think of, and they are the same for any image and not just launcher icons:
scaling might ruin the output image. it might make it blurry, pixelleted , or lose the wrong pixels. when you create the exact icons you wish to use, you will always know what you get. this is because the images are not vector-based so they can't scale nicely.
here's a quote from the documentation:
To ensure your bitmaps look their best, you should include alternative
versions at different resolutions for different screen densities.
scaling takes CPU time from the device. sure, it might not be important, but it's something...
the disadvantage is that your app will take more space.
so, what i think is that for some images you should create all of the density screens, and for some you can use xhdpi or xxhdpi (or even hdpi) images and not use the others.
btw, there is also xxhdpi launcher icon which is 144x144 (see here)
I need my application to support hdpi devices.
From what I've read, I need to use 72x72 size for icons, and 640x480 for images.
My questions are:
If my android device is mdpi for example, will is scale the images and the icons by itself ? I've read that it has a fair view after scaling.
Where should I place all my resources ? only in drawbles\hdpi folder ? or only in drawbles folder?
For #1, yes, it will scale them, but in my opinion you should always provide scaled resources of your own. This way you have control over how they look when downscaled (this makes more of a difference the smaller and more detailed they are). Also, 640x480 is by no means a standard size. It depends on what type of image you're wanting, and how large it needs to be. What's important is to understand the ratio between densities.
For #2, you should always have fallback graphics in the res/drawable folder, as Android will not upscale density specific graphics. (e.g. if you're running on an xhdpi Galaxy Nexus, your application will crash)
Have a look at the android developer docs regarding supporting multiple screens here:
http://developer.android.com/guide/practices/screens_support.html
In short, it is good practice to scale all your images to support multiple screen sizes and densities and put them in the respective folders like:
res/drawable-mdpi/my_icon.png // bitmap for medium density
res/drawable-hdpi/my_icon.png // bitmap for high density
res/drawable-xhdpi/my_icon.png // bitmap for extra high density
and leave it to the Android OS to select the correct image depending on the client device
So, in regards to this stackoverflow accepted answer: How do I convert ppi into dpi for Android images?
So, ok, i make each background image the dimensions that that guy specifies in the answer.
BUT, if i define the other ImageViews (smaller ones), that are placed on the screen, in relation to the sizes defined above (e.g. let's say an ImageView has dimensions 20x20 for the hdpi devices, if i calculate this dimensions for the ldpi devices, the image would have to be 7x7 pixels, which is terribly small) then the ldpi devices won't be able to see anything on the screen :) Or will they? Am i doing it right, or not?
I'm terribly confused. Can someone clarify this for me please? :)
The resolutions mentioned in the other question will always fill the screen, but you should provide different layout files for each screen size to stay dpi independent (if you so wish).
Look at the example from the dev page
Also, it always helps to fire up the appropriate simulator (middle size with mdpi, smallest size with ldpi and biggest size with hdpi, depending on what devices you are planning to support) and try your layouts out.
Your images should be at least the size which can be easily viewable, or even clickable for the user on his/her devices.
The guidelines are for specific images, like launcher icons, or menu items, and not necessarily for any images you use in your app. For these kind of images, you are the best judge of specifying the image sizes and resolutions.
You could well have those images as only mdpi, and supply an hdpi version, so that it atleast has a higher resolution image for hdpi and xdpi devices.
How large should be the image in pixels to fit all resolutions?
480x800 or 480x854?
I need to do different image resolutions for all folders:drawable-hdpi , drawable-ldpi, drawable-mdpi?and if so, which resolutions are used?
Thanks
You want an image that will fill the entire screen? There are over 50 supported android phones, each with a different resolution. You can't expect to create an image of the exact size of each phone. Instead, you'll probably need to come up with a few different versions and then allow it to stretch to fill the full screen.
hdpi, ldpi, mdpi refers the density of pixels on the screen, not the screen size. Thus, one mdpi screen might be 320x480 while another might be 480x854.
Supporting multiple screens has lots of good information dealing with the different screen sizes and densities. Icon design has specific suggestions for pixels sizes for different icons at the different screen densities.
Jovan, without knowing the type and context of the image you are referring to, this is difficult for me to answer directly. I assume you have drawn the 480x800 / 480x854 numbers from the high density WVGA and FWVGA total screen sizes. The android developer article on screen size support may help: http://developer.android.com/guide/practices/screens_support.html
Yes, if your app will target multiple device with different densities.
Please check the table in the link bellows to see the different resolutions in each folder:
http://developer.android.com/guide/practices/screens_support.html