Last active
May 13, 2016 13:26
-
-
Save BrunoVT1992/21bd6e9e7cd8bf9c39e351a133898476 to your computer and use it in GitHub Desktop.
Converter to convert dpi sizes to pixel sizes in Xamarin Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Android.App; | |
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