Xamarin.DeviceDensity.Plugin 0.0.3

dotnet add package Xamarin.DeviceDensity.Plugin --version 0.0.3                
NuGet\Install-Package Xamarin.DeviceDensity.Plugin -Version 0.0.3                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Xamarin.DeviceDensity.Plugin" Version="0.0.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Xamarin.DeviceDensity.Plugin --version 0.0.3                
#r "nuget: Xamarin.DeviceDensity.Plugin, 0.0.3"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Xamarin.DeviceDensity.Plugin as a Cake Addin
#addin nuget:?package=Xamarin.DeviceDensity.Plugin&version=0.0.3

// Install Xamarin.DeviceDensity.Plugin as a Cake Tool
#tool nuget:?package=Xamarin.DeviceDensity.Plugin&version=0.0.3                

<img src="images/logo.png" width="112" />

Xamarin.DeviceDensity.Plugin

NuGet

A Xamarin.Forms library to help with building a pixel perfect UI/UX across multiple screen size. While building a mobile application one needs to support multiple device screen size used by users as mobile devices comes in all shapes and sizes so your app layout needs to be flexible and your layout should gracefully respond to different screen sizes and orientations. Android uses alternative layout to fix that. While iOS uses adaptive layout concept to go around that. This package uses the device screen denisty to set the appropriate value for whatever you need it for. Be it Label font size or Button corner radius and even Frame height etc.

To further understand why device density is key to achieving this is explained by dpilove

In the context of screens, DPI (Dots Per Inch) or PPI (Pixels Per Inch) refer to the number of device pixels per inch, also called “pixel density”. The higher the number, the smaller the size of the pixels, so graphics are perceived as more crisp and less pixelated.

Each mobile device has a device density which ranges from 1.0 through to ~4.0.

Setup

  • To use the library in your project, follow the step(s) below.
  1. Download the latest version through NuGet and install it in your Xamarin.Forms standard project.

How to use

  1. Add this line to your xaml
xmlns:density="clr-namespace:Xamarin.DeviceDensity.Plugin;assembly=Xamarin.DeviceDensity.Plugin"
  1. For any view property that needs to vary across device density. For instance, a Label that needs to render differently on multiple device density.
<Label FontSize="{density:OnScreenDensityDouble Default=10, OnePointZero=8, OnePointFive=8, TwoPointZero=10, TwoPointFive=10, ThreePointZero=12, ThreePointFive=12, FourPointZero=14}" Text="Start developing now" />

Or a Button that has different corner radius across multiple device screen.

<Button CornerRadius="{density:OnScreenDensityDouble Default=10, OnePointZero=8, OnePointFive=8, TwoPointZero=10, TwoPointFive=10, ThreePointZero=12, ThreePointFive=12, FourPointZero=14}" Text="Start developing now" />

Images

Below are screenshots of a file new Xamarin forms shell project before making use of the plugin. The iPhone 12 Pro Max uses a 3.0 density while the iPhone SE makes use of 2.0 device density,

Before

<br/>

<img src="images/before.png" /> <br/> <br/>

After

You can see how crisp the layout looks on both screen type. <br/> <br/>

<img src="images/after.png" />

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.0.3 620 10/30/2021
0.0.2 1,025 10/2/2021
0.0.1 314 10/1/2021