I need to get DPI device in my Xamarin class PCL. I do not want to use Xamarin.Essentials. Can I do this using Native interfaces, if its possible, how can I do it?
相关问题
- Xamarin. The name 'authorEntry does not exist
- How to implement only emoji keyboard for Entry?
- Error:Xamarin.Forms targets have been imported mul
- Store data and global variables using the Applicat
- Is it possible to use NSUbiquitousKeyValueStore wi
相关文章
- Xamarin form MessagingCenter Unsubscribe is not wo
- Reload data on tab selected in a fragment using vi
- The type initializer for 'SQLite.SQLiteConnect
- What to use for AttributeName in Xamarin Mac
- Start an Activity from another Activity on Xamarin
- Xamarin build error: defining a default interface
- Xamarin Android Player Error when attempting to fi
- How to change the Back Button Text on Xamarin.Form
Currently Device Display Information available via official Xamarin.Essentials nuget package, see: https://docs.microsoft.com/en-us/xamarin/essentials/device-display
in your pcl create a new interface called IDisplayInfo:
In your android implementation, add a new class:
and in the iOS implementation, add the same class:
Now in your shared code, you can call
and should be good to go. Note that i also added methods for getting screen width and height, basically because i already had them in my code and since you are probably going to need them sooner or later anyways.
I have a
static class Core
to store some shared stuff defined the shared code. On app start it's receiving values for later use everywhere:Android MainActivity OnCreate:
iOS AppDelegate FinishedLaunching: