Image Sizes for the Android Application

Simple picture Simple · Sep 20, 2013 · Viewed 19.1k times · Source

Sorry I know earlier some people have same kind of questions but I am suffering from the same issue and don't get a clear view from the earlier questions.

I found Android very complex for the developer to deal with Multiple dimensions. Like there are devices from ldpi to xxhdpi and tablets.

What I have observed is there are different folder structure for the Images like ldpi, mdpi, hdpi and xhdpi and for tablets sw-600dp(7inch) and sw720dp(10inch).

Now the problem is there are many handsets have size 5 inch but there resolution is different and for tablets also the case is same. So I am confused and what size of images I asked to make to Designer for different handsets and mobile because resolution is very from device to device.

I also check the links http://developer.android.com/training/basics/supporting-devices/screens.html But didn't clear idea.

I am new to android . Please guide me how to solve this issue.

Answer

Tamas picture Tamas · Sep 20, 2013

Pick your device targets up front and stick to it. Check what's the biggest resolution popular device on the market today (samsung galaxy s4(1080p), nexus 7(1080p), nexus 10 (2560×1600), etc).

Do your designs/graphics in the biggest resolution available on a physical device.

There are 3 kinds of images:

  1. can be made into a 9patch (Ask yourself..could this be done in xml? If it is only made of simple shapes, just redo it in xml)
  2. can be redone in xml drawables (gradients, shapes whatever)
  3. can only be scaled or cropped (like a photo)

Working with 9patches is a pain in the ass, and IMHO should be avoided at all costs. Even if you make a very nice 9patch, you still have to scale it to every possible resolution that you want to support, which will increase the apk size. With xml files, you don't have to care about that, and you will be forward compatible, when somebody introduces a bigger resolution device in the future (they will).

Example:

Simple gradient dialog background(100x400 resolution in xhdpi) in all resolutions that I support in the app that I'm working on (l,m,h,xhdpi) is 20Kb. In xml it would be <1Kb.

But yeah, if you still want to use 9patches, just do it once in the biggest resolution that you care about(xhdpi), and use a resizer tool to get all the other resolutions. It will create the proper drawable folder structure for you!

About number 3:

So you have some images that can not be remade in xml, nor can be 9patched. Even if you have just a few (2-3) full screen images(backgrounds), you will run out of memory. There are some tools that could help with that, like universal image loader. Of course, if you have only small images, you are probably safe.

In eclipse, the layout editor has a nice preview feature, set it up properly so you can always see all the resolutions and aspect ratios that you care about.

To sum it up, tell your designer to do different designs for phones, 7" tablets, 10" tablets only in the biggest available resolution that a device (in that category) on the market today has. Also, do learn how to use xml drawables.