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

不想你离开。 提交于 2019-12-25 05:02:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!