Skip to content

Instantly share code, notes, and snippets.

@BrunoVT1992
Last active April 26, 2016 07:39
Show Gist options
  • Save BrunoVT1992/48f43bae10a67ce661a2552eb5f86aa4 to your computer and use it in GitHub Desktop.
Save BrunoVT1992/48f43bae10a67ce661a2552eb5f86aa4 to your computer and use it in GitHub Desktop.
Dpi to pixel converter for Xamarin Android
using Android.Content;
namespace Droid
{
public static class DpiToPixelConverter
{
public static int Convert(int dpi)
{
float scale = Application.Context.Resources.DisplayMetrics.Density;
return (int)(dpi * scale + 0.5f);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment