Android xxxhdpi drawable resolution auto resize - android

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.

Related

Android Developer Vs Android Designing

This is the question of its own kind may be some one has come across same condition which I have to face many times when it comes on UI and graphics.
And insist to forget about different screen sizes and resolution and just focus on the dps. Where as all the designers focus on the Resolutions and pixels.
So if I have to make the background screen for the splash activity so then What I am supposed to tell him If I want him to design for all folders I mean
mdpi, hpi, xhdpi , xxhdpi , xxxhdpi.
So first question is what size should I tell them to draw and for mdpi and hdpi and xhdpi and xxhdpi and xxxhdpi ? what should I tell them ?
Android designing is I think really very tough if you want to support different devices of different densities.
what would you suggest to make the the Graphics for all devices and what resolution should be the starting point ?
In the particular case of images that are meant to be backgrounds, it's okay to have a reasonably large image (1280x1920) and stick it in the drawable-nodpi folder.
Otherwise, for icons, your designer needs to learn about dp sizes. Then ideally they'll create a nice big high-res icon (say 512x512px), and either you or they will scale it to the appropriate sizes using something like Android Asset Studio
Tell your designer to make high resolution image,that means xxxhdpi or xxhdpi as per your requirement. so that we can converting it to lower resolution.
If you are using android studio then you can try this plugin.
by this you have to use Scaled Drawable import

About Android resources and screen densities

I am developing android apps for years now, and I always struggled with the part of resizing all icons for all different screen densities.
A couple of days ago I developed a utility for making this task easy and released it's source. But I received the following comment:
"If you have a mdpi device, and an app only has xhdpi resources, the system will scale the xhdpi resources down to mdpi size automatically."
So, I should not create all icons in different sizes for all screen densities??? Have I been wasting effort and time all this years?
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.
http://developer.android.com/guide/practices/screens_support.html
But you did not wast effort and time because to ensure your bitmaps look their best, you should include alternative versions at different resolutions for different screen densities.
Also this will give better performance

Why do we (have) to use different launcher icons (xhdpi, hdpi, etc)

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)

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.

Images for hdpi screen density

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

Categories

Resources