1
\$\begingroup\$

I was adding images after reading in the documentation:

This means that if you generate a 200x200 image for xhdpi devices, you should generate the same resource in 150x150 for hdpi, 100x100 for mdpi and finally a 75x75 image for ldpi devices.

So should my images in XHDPI be 200x200 pixels, my images in HDPI be 150x150 pixels, my images in MDPI be 100x100, and my images in LDPI be 75x75? After reading the documentation, that is what I thought, but when I came across this page:

https://stackoverflow.com/questions/19875158/android-background-image-size-in-pixel

The answers state to use different pixeol amounts for the different directories. I am very confused now on what to do. Here is what I have here right now, please tell me if I am doing this correct:

enter image description here

So basically, I spent the past 4-5 hours re-sizing lots of my images to the sizes in those folders. Now I'm thinking...did I even re-size them correctly? Is it supposed to be 100x100 for mdpi? I really need to use these images for my 2d game.

Basically, I just want to know if the directories are supposed to have that many pixels each. Because the question I linked says otherwise.

Thanks so much,

Ruchir

\$\endgroup\$
1
\$\begingroup\$

Don't get caught up in the exact numbers used in the example. Those are not the main point. It's how they are relative to each other. You see that xhdpi 200x200 is twice as big as mdpi 100x100. Notice the if in the example.

List of densities:

  • xxhdpi: 3.0
  • xhdpi: 2.0
  • hdpi: 1.5
  • mdpi: 1.0 (baseline)
  • ldpi: 0.75

Sample example but with different numbers:

This means that if you generate a 512x512 image for xhdpi devices, you should generate the same resource in 384x384 for hdpi, 256x256 for mdpi and finally a 192x192 image for ldpi devices.

  • 512 = 256 * 2
  • 384 = 256 * 1.5
  • 256 = 256 * 1
  • 192 = 256 * 0.75

So just figure out whatever size you want in pixels for whatever display density your phone is, and then calculate the size of any other densities from the multiplier above. If a 90x90 images looks good on your hdpi phone, then use that on hdpi and calculate the others and re-size the image. E.g. xhdpi would be 120x120 in this case.

\$\endgroup\$
  • \$\begingroup\$ Ok Christer, that cleared it up for me. At this point I understand how I would rescale my images based on what would look best in the screen I test on, but what I'm unsure about is the rescaling itself. Because android will already rescale the images, and it may be blurry, how am I to rescale the images without it becoming blurry? Essentially, isn't it the same if I rescale my image and if android rescales my image? I know android will pick based on the directory the image is in, but how do I get the image to look clear for the sizes that I will use? I understand the scaling part now though ☺ \$\endgroup\$ – Ruchir Baronia Jan 23 '16 at 18:31
  • \$\begingroup\$ Sorry, my first comment posted before I typed it up, and the edit didn't go through. \$\endgroup\$ – Ruchir Baronia Jan 23 '16 at 18:32
  • \$\begingroup\$ @RuchirBaronia I don't know what kind of downsampling android uses and if it can be changed, but if you use something like photoshop you can select that yourself and hopefully it won't be blurry. If your image is vector graphics you can directly render it out to all of these resolutions. I can't say how to not make them blurry, but at least making the images before hand gives you more control, like if the image has text you might want to make the lower density version have bigger text. Also uses less memory since the image is smaller compared to just having one high density version. \$\endgroup\$ – Christer Jan 23 '16 at 18:54
  • \$\begingroup\$ Christer, I have been stuck on deleting items from a simple list view. gamedev.stackexchange.com/questions/115881/change-list-in-game \$\endgroup\$ – Ruchir Baronia Jan 31 '16 at 2:18
  • \$\begingroup\$ Can you help me on this? gamedev.stackexchange.com/questions/119292/… \$\endgroup\$ – Ruchir Baronia Apr 3 '16 at 20:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.