which resolution images to design for different android drawables folder - android

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!

Related

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.

PSD file dimensions and resolution for Android app design

I heard and read different things regarding what should be the PSD file's dimensions and resolution for designing Android apps. Unfortunately, I came across different approaches for configuring PSD files, which I found confusing.
This page in Android Developer site says a lot about supporting screen sizes, but does not show how to configure the PSD files: http://developer.android.com/guide/practices/screens_support.html
So, in order to clarify this issue I will present the approach I take, and I would love to hear comments about it.
How I set the PSD:
I set the PSD's dimensions to 480x800 px (for portrait), and I set the resolution according to the current screen density I want to support, meaning:
320 Pixel/Inch for xhdpi
240 Pixel/Inch for hdpi
160 Pixel/Inch for mdpi
120 Pixel/Inch for ldpi
213 Pixel/Inch for tvdpi
(see the link above regarding screen support to understand why to use these numbers)
So what I do is design for the highest density I want for my app (say for example hdpi) and export, then I change the resolution the the next lower density (mdpi) and export and so on...
As for launcher icons, it is specified how to build the icons at:
http://developer.android.com/guide/practices/ui_guidelines/icon_design_launcher.html#size
All of the templates I found for icons used a 72 Pixel/Inch resolution in the PSD.
Edit:
So to make my question clear - is this approach correct? is it recommended?
Never assume a pixel size for your screen (e.g. 480x800 is a no go), you never know what your size or aspect ratio is going to be, and assuming these things is going to make your life very difficult in the future.
You should start at the highest resolution you can (it's not going to be long before XXHDPI is going to be more common), and work down from there. Determine what size the graphic needs to be. If you want it to be about an inch wide, multiply it by the density (e.g. 1 * 320 for XHDPI, 1 * 160 for MDPI, 1 * 240 for HDPI) to get the pixel size.
The DPI setting in Photoshop does not matter. People get confused and think it does, but for designing graphics for screens, it's irrelevant unless you want to check the physical size (e.g. if you set the document density to 320 dpi, and then check the image size, it should show you what the physical size -- such as inches -- is for a screen of that density). When creating a new document, you could create a new document at say 1 inch by 0.5 inch, at 320 dpi, and it will create it at the correct pixel size. I'd advise against it. Stick to pixel sizes that are multiples of 4 for the best quality when resizing.
Basically, take a more generic approach -- design the graphics you need at the highest resolution you plan to support, find areas where the size is flexible, and if necessary make stretchable 9-patch images for those areas. Then create versions for the lower densities once you've finished that.

Correct graphics for Android devices in regard to small/normal/large/xlarge and ldpi/mdpi/hdpi/xhdpi?

Im new to Android development and Im still a bit confused about making the correct graphics for the different devices. In this document there is a table listing different screen resolutions and density but it confuses me... Now lets take a example. I need a full screen background for my app, so making the largest background image 800x1280 for Galaxy Note seems about right for me (I don't want to support tablets, only phones), and then I could make a 720x1280 for Galaxy S3 and its likes and 480x800 version for Galaxy S2 and its likes, but where should I then place those image files?
It seems to me that all those devices are in the high density range, but then how do the devices use the correct graphics? Should I manually control this, or should I simply use just one and the same graphics for all devices and let Android scale it (then there are the problem with aspect ratio, how do I overcome that?)?
Thank you
Søren
In resource folder, you can create drawable directories according to width/height.
Then, you can use resource qualifiers, for width - wdp or Examples: w720dp,w1024dp etc.
for height hdp. Examples:h720dp, h1024dp etc.
Alternatively you can categories Screen size as small, normal, and large and can place your images in respective drawables.
Refer to this post : http://developer.android.com/guide/topics/resources/providing-resources.html#QualifierRules
small: QVGA low density and VGA high density.
normal: WQVGA low density, HVGA medium density, WVGA high density.
large: VGA and WVGA medium density screens.
xlarge: HVGA screen. The minimum layout size for an xlarge screen is approximately 720x960 dp units.
Everything is provided at developer site. Please refer to this link
The answer posted by yogeshhkumarr is correct, but it is worth noting that, depending on what sort of background images you are using, you may be able to make use of a 9-patch image to solve your problem without having to make multiple versions of the same image.

Android. ldpi, mdpi, hdpi clarification

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.

Categories

Resources