Search code examples
androidbitmapscreenscaleresolution

How do you tell Android not to scale images?


I have some pictures in the /drawable folder, which to my understanding is intepreted as /drawable-mdpi. Now these images are scaled when being used (depending on the device). I don't want to add more pictures, because they don't exist. And I don't have the resources to create different res pictures.

I just want the pictures to appear smaller on bigger devices. Is there a way of not scaling the images?

I'd hate to have to hard-code all the picture sizes.

This is the second question, as edits aren't attracting attention at all. Sorry about that.


Solution

  • Adding the BitmapFactory.Options parameter to the decodeResource with the flag inScaled set to false is how to do it

    BitmapFactory.Options mNoScale = new BitmapFactory.Options();
    mNoScale.inScaled = false;
    BitmapFactory.decodeResource(getResources(), R.drawable.id, mNoScale);