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

Martin Brinkmann
Development

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.

Comments

  1. Anonymous said on
    Reply

    you save my life, thanks.

  2. Anonymous said on
    Reply

    thks u so much . tool is good

    1. sayali said on
      Reply

      thank you so much

  3. Expz said on
    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
      Reply

      This works seemlessly, Great site.

  4. vineet said on
    Reply

    great …. its very helpful

  5. Anonymous said on
    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
    Reply

    Thanks …. Really very helpfull :)

  7. cypis said on
    Reply

    Thanks! It was very helpful

Leave a Reply

By commenting, you accept our privacy policy and keep the discussion respectful and on topic.