Disable Pre-Scaling of Android Image Resources

As more Android powered tablets are released and announced, more developers should be making sure that their applications are optimized for them. In Android this means firstly stating that the application can handle any screen size with the following code.

android:anyDensity="true" />

Place this in your application’s AndroidManifest.xml file inside the <Application> tags.

However, this didn’t solve all my problems. While enabling my application to run full-screen on tablets without a big black border, it did some funky things with my image sizing. To accomodate large displays Android automatically scales Bitmap images to the display’s dpi. If you are using pixels for placement and sizing of images, like me, this can really screw up the way your app looks.


Drawable resources are stored in /res/drawable. However there are several other drawable directories you can use to support different things. I just wanted to disable scaling altogether. No matter what dpi the screen is, I want to draw my Bitmap at it’s native size. To do this, place all of these images in the /res/drawable-nodpi directory. Any resources in this directory will never be scaled. You will not have to change anything in your code as the Android API automatically checks this directory for the image.

Learn more on the Android developer guide: Resource directory qualifiers for screen size and density

7 Responses to “Disable Pre-Scaling of Android Image Resources”

  1. Igor says:

    You could try to put following tags in tag (not in ):

  2. Teri says:

    Thank you. You made my day. I place images everywhere at the screen but also paint text and polygons at it. Therefore the autoscale feature makes everything confuse because the drawing operations are pixel oriented.

  3. Belal says:

    Thank you so much, its really great topic

  4. I am extremely inspired together with your writing abilities as neatly as with the format for your blog. Is this a paid subject matter or did you customize it your self? Anyway stay up the nice quality writing, it’s rare to peer a nice weblog like this one nowadays..

  5. tunisie jeux says:

    I have been exploring for a little bit for any high quality articles or weblog posts in this sort of area . Exploring in Yahoo I eventually stumbled upon this web site. Reading this information So i am glad to convey that I’ve an incredibly just right uncanny feeling I came upon exactly what I needed. I such a lot undoubtedly will make sure to don?t omit this web site and provides it a look regularly.

  6. Great items from you, man. I have understand your
    stuff previous to and you are simply extremely magnificent.
    I actually like what you have obtained right here, certainly like what you’re saying and the way in which during which
    you are saying it. You make it enjoyable and you still take care of to
    stay it wise. I cant wait to read far more from
    you. That is really a wonderful site.

  7. apk free says:

    I like the helpful info you supply in your articles. I will bookmark your weblog and test again here frequently. I’m relatively sure I’ll be informed lots of new stuff proper here! Best of luck for the following!

Leave a Reply