MonoDroid apps do not use the correct density

I get very interesting results when testing an application developed using MonoDroid on different devices with different screen sizes and densities.

I have the following (simplified) folder structure created in my project:

  • range hood
    • image.png
  • draw-ldpi
    • image.png
  • draw-mdpi
    • image.png
  • draw-HDI
    • image.png
  • draw xhdpi
    • image.png

The image in the drawing is a folder. Images in other folders are identical, except for the size and letters that are drawn on top to indicate what density it is (for example, L, M, H or X) depending on the folder.

Regardless of the screen density of the device (verified using Android.Util.DisplayMetrics), the images displayed for the application are displayed from the drawable-mdpi folder.

I created a quick test application in Eclipse that used the same xml layout file and the same set of images. Running this application on different devices displays the correct image.

I am in complete loss, and now it has cost me the best part of a two-day diagnosis and, finally, to identify the cause of the problem.

Has anyone been able to overcome this problem? Thanks in advance!

+1
android dpi resolution xamarin.android
source share
1 answer

After talking with Xamarin support, it turns out that the problem is with the wrong AndroidManifest.xml file ...

He did not have <uses-sdk> the tag was set correctly ...

Change it out

<uses-sdk /> <!-- Why in the world this is the default I'll never know! --> 

to that

  <uses-sdk android:minSdkVersion="8" targetSdkVersion="8"/> 

completely solved the problem.

Hope others find this helpful!

+3
source share

All Articles