Reputation: 815
I need to get a screen size in dpi. I've seen a way to use the XLabs library, can I do without it
Upvotes: 2
Views: 1843
Reputation: 1847
In Forms I think that you can do only this:
App.AppContext.ScreenSize.Width
App.AppContext.ScreenSize.Height
But you can obviously create a custom renderer, and in Android you have also these properties:
Context.Resources.DisplayMetrics.Xdpi
Context.Resources.DisplayMetrics.Ydpi
While in iOS these:
UIScreen.MainScreen.Bounds.Width
UIScreen.MainScreen.Bounds.Height
For UWP these:
var display = Windows.Graphics.Display.DisplayInformation.GetForCurrentView();
double xDpi = display.RawDpiX;
double yDpi = display.RawDpiY;
Upvotes: 3