Create Android HDPI, MDPI and LDPI images out of a single XHDPI PNG image - gHacks Tech News

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

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.





  • We need your help

    Advertising revenue is falling fast across the Internet, and independently-run sites like Ghacks are hit hardest by it. The advertising model in its current form is coming to an end, and we have to find other ways to continue operating this site.

    We are committed to keeping our content free and independent, which means no paywalls, no sponsored posts, no annoying ad formats (video ads) or subscription fees.

    If you like our content, and would like to help, please consider making a contribution:

    Comments

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

      Thanks! It was very helpful

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

      Thanks …. Really very helpfull :)

    3. 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! :)

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

      great …. its very helpful

    5. 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.

    6. 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

    Leave a Reply