问题
I am getting some very interesting results when testing an app developed with MonoDroid on different devices with varying screen sizes and densities.
I have the following (simplified) folder structure set up in my project:
- drawable
- image.png
- drawable-ldpi
- image.png
- drawable-mdpi
- image.png
- drawable-hdpi
- image.png
- drawable-xhdpi
- image.png
The image in drawable is that of a folder. The images in the other folders are identical except for the size and a letter that is drawn on top to indicate which density it is from (e.g. L, M, H, or X) depending on the folder.
Regardless of the device's screen density (verified using Android.Util.DisplayMetrics) the images displayed for the app are being pulled from the drawable-mdpi folder.
I created a quick test app in Eclipse that used the same xml layout file and the same set of images. Launching that app on my various devices displays the correct image.
I'm at a complete loss and this has now cost me the better part of 2 days diagnosing and finally detecting the cause of the problem.
Has anyone been able to overcome this problem? Thanks in advance!
回答1:
After chatting with Xamarin support it turns out that the problem was related to an incorrect AndroidManifest.xml file...
It didn't have the <uses-sdk> tag set correctly...
Changing it from
<uses-sdk /> <!-- Why in the world this is the default I'll never know! -->
to this
<uses-sdk android:minSdkVersion="8" targetSdkVersion="8"/>
completely solved the problem.
Hope others find this useful!
来源:https://stackoverflow.com/questions/8596917/monodroid-apps-dont-use-correct-density-drawables