• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps drawable-nodpi not working?

Deldri

Lurker
Hi everyone,

I got one image wich size is 64x64. It is placed in res/drawable-nodpi directory.

The image is getting scaled (to a tiny version) in a xxhdpi screen. Why? Isn't a resource in drawable-nodpi directory meant to not be scaled?

I have got minSDK 8 in manifest.

I'm also using:

BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inScaled = false;
icon = BitmapFactory.decodeResource(context.getResources(), R.drawable.icon, opts);

And drawing it in a canvas with drawBitmap(icon, 0, 0, paint);

I'm getting tired of trying a lot of things and not getting the right answer, if anyone knows please answer.

Thanks in advance.
 
Last edited:
nodpi does not auto scale, it just means it uses the same resource for any density. So a 64x64 image might look huge on a low density screen, but might look super tiny on a high density screen. From the android documentation:

Resources for all densities. These are density-independent resources. The system does not scale resources tagged with this qualifier, regardless of the current screen's density.

If you are building a game, I would stop using canvas. I used to build games this way and the system runs out of memory very, very quickly, especially when scaling images to fit various screen sizes. For 2d games I now use sprite batcher, since it runs on OpenGL, you don't have these problems because it is very easy to scale images and the burden goes on the GPU instead of the CPU.

https://github.com/twicecircled/Android-Sprite-Batcher
 
Back
Top Bottom