[Xamarin]Get the Screen Height and convert for Height Request
That is impossible to detect screen size in the Xamarin Form. You have to do in the native Android code.l suggest to do in MainActivity and then put in the static variable in the Forms PCL project like this:
Android.Util.DisplayMetrics displayMetrics = new Android.Util.DisplayMetrics();
this.WindowManager.DefaultDisplay.GetMetrics(displayMetrics);
App.Height=(int)(displayMetrics.HeightPixels/displayMetrics.Density);
Also, the unit of HeightRequest is device-independent units. But I found if you use HeightPixel divide by Density of the screen, then it will convert into the unit for HeightRequest or WidthRequest
Trackback address for this post
Trackback URL (right click and copy shortcut/link location)
Feedback awaiting moderation
This post has 4460 feedbacks awaiting moderation...
Form is loading...