Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
I have Xamarin.Android 220.127.116.11. When testing my Android app, the '5" KitKat (4.4) XXHDPI Phone' emulator returns the density as 72 dpi. I guess it should be 480 dpi, if it claims to be XXHDPI.
The relevant code:
Activity currentActivity = this; // This code is called inside Activity object
Display d = currentActivity.WindowManager.DefaultDisplay;
Android.Util.DisplayMetrics m = new Android.Util.DisplayMetrics();
d.GetMetrics( m );
Check the value of:
This problem may be in other emulators as well, I didn't have time to test them.
To help pin down this issue, can you please provide a step-by-step reproduction of this issue so we can investigate further? The reason why we need a step-by-step is that we need to know what exactly is being added to your AVD. The AVD can be tricky because there are many things that might affect DPI such as the SKIN you pick, and if you select the "SCALE DISPLAY TO REAL SIZE" before booting.
The real test is to ensure your physical device works first. Once you ensure that's correct, then start playing around with your AVD to ensure the settings mimic a real world device instead of being shrunk. Thus I am marking this bug as NEEDINFO for the time being.
Created attachment 23315 [details]
Testing app to demostrate the DPI problem
Created attachment 23316 [details]
Screenshot 1 showing the emulator is not AVD but Xamarin
Created attachment 23317 [details]
Screenshot 2 showing my current list of AVDs
I have added a testing app and screenshots.
The device I am referring to is not a standard AVD device but Xamarin's own emulator so when I launch it it doesn't ask for 'Scale display to real size'.
My physical devices display correct DPI.
(In reply to Ales Suchac from comment #5)
> I have added a testing app and screenshots.
> The device I am referring to is not a standard AVD device but Xamarin's own
> emulator so when I launch it it doesn't ask for 'Scale display to real size'.
> My physical devices display correct DPI.
What do you mean Xamarin's own emulator? This is Microsoft's Emulator for Android. I don't believe it's readily available in newer versions of Visual Studio 2017(As they moved it to be an optional workload)
For example if you are using the AVDs from Google, you will be able to see the resolution of a device such as:
Google Pixel XL - 1440 x 2560; 560 dpi
When running the sample app on this emulator, I get the expected 560 dpi.
Now if I change this emulator to the regular Google Pixel, I would see the following:
Google Pixel - 1080 x 1920; xxhdpi
Running the sample app, I would see 480 dpi (Which is the threshold for xxdpi)
So I believe the issue might be with the emulator you are using. It looks like you're using the Visual Studio Emulator for Android, which unfortunately does not publish any new emulator images for Android updates. It is thus recommended to move to the Android Emulators that Google provides.
I highly recommend updating your Xamarin versions and installing Android Studio for an easier AVD Manager for the time being(As Google released avdmanager recently). I am thus marking this bug as RESOLVED ANSWERED as this behavior should work just fine on these emulators.
You are right that AVD emulators solve the problem, which I never disputed.
I just thought that the Microsoft's Visual Studio emulator is in fact a Xamarin's product so you might be able to fix it.
OK I agree we have the solution. Thank you.