Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why don't we use nodpi for all drawables?

Tags:

android

I'm not talking about the resource files like .9.png or .xml, but rather image files for icons and backgrounds. Isn't it much easier or more reliable to create a high definition image, put it inside of the nodpi folder, and then use properties like fitXY to fit the image inside a given space? Why go through all the trouble of creating a scaled version for mdpi, hdpi, xdpi, etc?

like image 633
Huy T Avatar asked Mar 23 '15 18:03

Huy T


People also ask

What is the preferred image format for the Drawables?

Supported file types are PNG (preferred), JPG (acceptable), and GIF (discouraged).

What means Nodpi?

nodpi : 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.

What do you mean by Drawables?

An object used to create frame-by-frame animations, defined by a series of Drawable objects, which can be used as a View object's background. ClipDrawable. A Drawable that clips another Drawable based on this Drawable's current level value.


1 Answers

Scaling down a large image to a smaller one before using it as an ImageView's source is more computationally expensive than being able to pull a properly sized one from a proper DPI bucket.

While it may be easier to slap your resources into a single drawable folder and call it good, it will cause performance issues when rendering assets on lower DPI devices, which tend to have less powerful CPUs anyway.

like image 80
Fargonaut Avatar answered Oct 04 '22 19:10

Fargonaut