Hi I need to know the density of screen in windows 10/8/8.1 and iOS. I got screen density in Android using DisplayMetrics but I find no such option/property available in UWP and iOS. So Is there any property through which I can get screen density in UWP and IOS.
相关问题
- How to implement only emoji keyboard for Entry?
- Error:Xamarin.Forms targets have been imported mul
- Microsoft store certification fails due to DPI awa
- C# [anonymous\generic] object to byte[] without Bi
- System.IO.MemoryMappedFiles on MonoTouch?
相关文章
- How to create a MediaClip from RenderTargetBitmap
- Xamarin form MessagingCenter Unsubscribe is not wo
- How to overlay items in StackPanel or ListView?
- C# UWP Toolkit DropShadowPanel inner shadow
- How to use native C++ libraries in Mono for Androi
- How to change the Back Button Text on Xamarin.Form
- Is there a RestSharp implementation that works wit
- UTF-16 safe substring in C# .NET
This list lists the ios device dpi information. You can also use
GBDeviceInfo
thrid-party tool to get the screen density for IOS device like this[GBDeviceInfo deviceInfo].displayInfo.pixelsPerInch;
IOS:
I found API in the UWP to retrieve the device dpi.
Windows.Graphics.Display.DisplayInformation
. You can try it.UPDATE - June 8th 2018
Xamarin has released Xamarin.Essentials!
You can now query the device's display information without having to manage all of the individual platform code pieces.
Device Display Information - https://docs.microsoft.com/en-us/xamarin/essentials/device-display
How-To:
Add a reference to Xamarin.Essentials in your class:
The following information is exposed through the API:
Useful Links:
(Github) Xamarin.Essentials - https://github.com/xamarin/Essentials
(Blog) Xamarin.Essentials - https://blog.xamarin.com/xamarin-essentials-cross-platform-apis-mobile-apps/
(Docs) Getting Started with Essentials - https://docs.microsoft.com/en-us/xamarin/essentials/get-started
Original Post (Before Xamarin.Essentials existed)
Below, I'm storing the specific OS's screen details in
static
vars, located in the Xamarin FormsApp
classThese all appear to work in my testing.
(copy/pasted from my github page - https://github.com/mattregul/Xamarin_Screensize)
Android (MainActivity.cs) - Jump to Github Page
iOS (AppDelegate.cs) - Jump to Github Page
Note In all Windows examples
screensize
is the root project namespaceUWP (App.xaml.cs) - Jump to Github Page
Windows Phone 8.1 (App.xaml.cs) - Jump to Github Page
Windows 8.1 (App.xaml.cs) - Jump to Github Page
Xamarin Forms Page (App.cs) - Jump to Github Page