问题
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.
回答1:
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
.
来源:https://stackoverflow.com/questions/11231533/why-android-uses-resources-from-the-higher-resource-instead-of-a-lower