Create Android HDPI, MDPI and LDPI images out of a single XHDPI PNG image

Martin Brinkmann
Apr 18, 2013
Development
|
9

I'm not the most advanced Android programmer yet but I have picked up a few things ever since I started to create my first basic apps for the platform. While it is possible to add a single png image as a resource to an Android project, it is also possible to use multiple versions of that same image instead. If there is only one image, it will be used regardless of the screen size and density of the Android device it runs on. The system scales and resizes images automatically if the need arises so that the application works on different screen sizes and densities if no matching image resource can be located. While that is better than not displaying images at all, it may lead to all kinds of issues including images that do not really look that good on particular devices.

The Android developer guide has a large page dedicated to images, screen sizes, density and all that good stuff. If you want to add multiple versions of the same image to your Android app, you need to know how to create those. While you can theoretically use any image editor or resizer for the task, you may want to check out the 9Patch Resizer tool instead which has been designed for exactly that task and automated so that you do not have to juggle around with values on your own.

So, instead of having to create multiple versions of the same image manually you simply create one version - the xhdpi version - and use the program to get all the other image versions created for you. You can repeat that process for all the images that you include in your application.

android resize dpi images

The program is available as an executable file for Windows and as a Java jar file for other operating systems. The executable file displays a basic interface that you can drop your xhdpi image in to. When you do, it will automaticlaly created the respective drawable-hdpi, drawable-ldpi and drawable-mdpi folders in the same root directory the image is stored in so that you can move them into your Android app project folders right away to include them in your application.

Advertisement

Previous Post: «
Next Post: «

Comments

  1. Anonymous said on April 24, 2020 at 1:04 am
    Reply

    you save my life, thanks.

  2. Anonymous said on February 5, 2017 at 6:19 pm
    Reply

    thks u so much . tool is good

    1. sayali said on March 6, 2017 at 8:06 am
      Reply

      thank you so much

  3. Expz said on December 3, 2016 at 11:55 am
    Reply

    You can create HDPI, MDPI and LDPI images online using tools like https://www.img-bak.in/ too. Just giving the info.

    1. AL said on March 5, 2017 at 8:21 pm
      Reply

      This works seemlessly, Great site.

  4. vineet said on August 14, 2016 at 2:16 pm
    Reply

    great …. its very helpful

  5. Anonymous said on August 13, 2016 at 8:22 am
    Reply

    Thank you so much. This is a very helpful tool and speeds up work flow. You are a life saver! :)

  6. Jan said on May 25, 2016 at 2:10 pm
    Reply

    Thanks …. Really very helpfull :)

  7. cypis said on December 9, 2013 at 2:40 pm
    Reply

    Thanks! It was very helpful

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.