Images for hdpi screen density - android

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

Related

What image (with smaller or higher DPI) is used to prepare the image when appropriate is missing?

I have phone with xhdpi screen. I use image abc.jpg but there is no such image for xhdpi. But there is an image with higher DPI (drawable-xxhdpi/abc.jpg) and with lower (drawable-hdpi/abc.jpg). Which one will be used to prepare (scale) the image for my density screen?
Excerpts from Android developers page:
Note: Using a density qualifier doesn't imply that the resources are
only for screens of that density. If you don't provide alternative
resources with qualifiers that better match the current device
configuration, the system may use whichever resources are the best
match.
Best Match:
If the qualifier in question is screen pixel density, Android selects
the option that most closely matches the device screen density. In
general, Android prefers scaling down a larger original image to
scaling up a smaller original image.
Source page : https://developer.android.com/guide/topics/resources/providing-resources.html#BestMatch
Based on this I'd assume that the higher dpi image will be used, however a visual check would probably confirm this i.e. if the image isn't blurry it is probably safe to assume it hasn't been upscaled.

Android xxxhdpi drawable resolution auto resize

If I add a large image to xxxhdpi folder does it gets resized automatically by Android to smaller images for other screen resolutions?
And if yes from which version of Android is this supported?
You shouldn't really need xxxhdpi. It was only introduced because of the way that launcher icons are scaled on the Nexus 5's launcher.
So throw your image into xxhdpi and it will scale down for other devices. The only issue you'll have is quality. You'd get higher quality out of the image if you scale it yourself.
Adding to my comment, this is from Android Developers - Supporting Multiple Screens.
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.
And from a Roman Nurik post
I talk about some of the key aspects of Android 4.4 KitKat that all Android designers should be aware of. Specifically:... 7) The introduction of new XXXHDPI (640dpi) launcher icon assets due to the Nexus 5 launcher's icon scaling behavior.
So it seems that it will scale, and that the resolution xxxhdpi is a newer implementation. I really would avoid using xxxhdpi images in an application unless you plan on using them specifically and for a good reason as they are going to be large files.
Edit
It does seem xxxhdpi was introduced in 4.3, as stated in this Android Police Article. Either way, it hasn't been around for long and isn't used by many devices at this point, so I still say that unless you have an explicit reason to use a xxxhdpi image it isn't worth the space and scaling issues you might encounter by using it.
It was first spotted in the 4.3 source (see Android Police) and its distribution is currently less than 0.1% (see Screen Sizes and Densities). Although the images would scale down you should include lower resolutions (I would go with mdpi, hdpi and xhdpi without xxxhdpi) to ensure both high image quality and high performance.

Supporting Multiple Screens for hundreds of icons

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.

Android: Recommendations for background image sizes for different screen densities?

Which is the correct sizes of background images for the different densities ldpi, mdpi, hdpi, xhdpi, xxhdpi?
I have transparent background images (.png) and want to reduce image size as much as possible. (not concerning the .apk size, but concerning memory issues on lesser powerful devices)
I assume, the first thing is to make sure the images are in the correct sizes, so that they do not need to be scaled. However, I don't know how the densities relate to certain screen resolutions (if any).
What other options are available to reduce image size . I am using GIMP to create the background images. Which settings should I use in GIMP?
Any recommendations?
EDIT:
Should a device with a 800 x 480 pixel screen use a background image of 800 x 480 pixel?
Android would not have to scale it, but on the other hand, the image would require a significant amount of memory?
What would be the best resolution?
And how do I know which devices have which screen size?
I.e. the SGS GT-I9000 has 800 x 480, but is a ldpi device (only 233 dpi).
The only solution I know for this is using 9-patch. Of course, it puts a restriction on the nature of the background you are using but in most cases it solves the problem.
http://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch

Which is the PSD size for supporting normal and large screen size?

I am developing an Android App which has to support only normal and large size devices and all densities. I read the Android documents "Support Multiple Screen Size", but I am a little bit confused... I understand how to provide different resources for different densities, but not which is the baseline resolution to use. HVGA seems to be old.
My graphic designer wants to know how to set the .PSD size in order to export graphics at the right dimension for supporting normal and large screen size.
Assuming that he works with mdpi (~160dpi)and then he will export the images in ldpi and hdpi with the appropriate scale factor, the question is: which resolution should have the PSD?
What do you suggest me to tell him? I don't know how is the best practice to follow.
I would say the size of the largest resolution you will support. Then downscale from there for lower densities (or let the OS handle the rescaling, but I think your designer would prefer to rescale himself. There's no one exact resolution, as there are a variety of resolutions and aspect ratios to support. Just keep any relevant details in the image away from the far edges, size for a particular aspect ratio (or 2) something like 16:9 or 4:3 and just work your way down from there.

Categories

Resources