sandalone
sandalone

Reputation: 41749

Why Android uses resources from the higher resource instead of a lower?

There is an app which I want to adopt to xhdpi resolution phones. So I made resources for that resolution and all went fine regarding the xhdpi phones.

I have a test mobile phone which is normal hdpi and the layout is now messed up (after I made fixes for xhdpi phones.

The layout structure looks like this:

/res/drawable-hdpi
/res/drawable-normal-xhdpi
/res/layout
/res/layout-normal-xhdpi

When I load the app on normal hdpi phone, I see that it uses layout from /res/layout-normal-xhdpi and images from /res/drawable-normal-xhdpi.

Shouldn't it use resources from the lower resource folder like /res/layout and /res/drawable-hdpi? It does not and I do not know why.

Upvotes: 0

Views: 208

Answers (1)

Vit Khudenko
Vit Khudenko

Reputation: 28418

According to How Android Finds the Best-matching Resource system eliminates resource files that contradict the device configuration, but it looks like your case is expected, because of this exception:

Exception: Screen pixel density is the one qualifier that is not eliminated due to a contradiction.

This way a device of normal hdpi configuration matches to /res/drawable-normal-xhdpi.

Upvotes: 1

Related Questions