Xander
Xander

Reputation: 5597

What will happen on screens if there's no resource for that screen density?

I've got a resource in 3 different sizes. I've put one of them in drawable-hdpi, one in drawable-mdpi and one in drawable-xhdpi. Now I wonder what will happen if I run the application on a device with ldpi (or with tvdpi or nodpi if that's possible??) Would it be better maybe to put one resource in the drawable folder as well?

Upvotes: 1

Views: 182

Answers (3)

Manolo Garcia
Manolo Garcia

Reputation: 3805

You have to be careful about put images in Drawable folder without any qualifier. The images in the unqualified folder are the same that images in mdpi, so if you have a big image in the unqualified folder and you try to assign it to an ImageView in an xhdpi phone, Android will try to scale up your image, and probably it will create a "Out of memory on a XXXXXX-byte allocation"

Upvotes: 0

Raghav Sood
Raghav Sood

Reputation: 82583

On the most of the devices, Android will pick the nearest available resource from the other drawable folders (like picking from ldpi or hdpi if mdpi isn't available).

However, on some devices the system may not pick up resources from other folders, due to a buggy implementation.

As a best practice, you should always keep a copy of each resource in the completely unqualified folders (drawable, values etc)/

Upvotes: 2

HalR
HalR

Reputation: 11083

Your system will pick the "best" available resource and size it accordingly. With ldpi, it may take an hdpi and cut it in half.

With tvdpi, it may be me, but I was usually surprised with what it was picking for me.

Upvotes: 3

Related Questions