Created
April 29, 2016 17:46
-
-
Save baileysh9/b9a831a61576edf28e19b631b2c7b7b1 to your computer and use it in GitHub Desktop.
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
protected override void OnCreate (Bundle bundle) | |
{ | |
base.OnCreate (bundle); | |
global::Xamarin.Forms.Forms.Init (this, bundle); | |
var metrics = Resources.DisplayMetrics; | |
var widthInDp = ConvertPixelsToDp(metrics.WidthPixels); | |
var heightInDp = ConvertPixelsToDp(metrics.HeightPixels); | |
App.ScreenWidth = metrics.WidthPixels; | |
App.ScreenHeight = metrics.HeightPixels; | |
LoadApplication (new App ()); | |
} | |
public int ConvertPixelsToDp(float pixelValue) | |
{ | |
var dp = (int) ((pixelValue)/Resources.DisplayMetrics.Density); | |
return dp; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment