Android Project: DPI

Does anyone know how to calculate the DPI in an Android Project?
I’ve got the current screen resolution, but I can’t work out how to get the actual screen size in inches.

Assuming you’re using .NET 6 (MG 3.8.1): add Maui Essentials (replaces Xamarin Essentials) via .csproj:

Getting DPI and other display info: Device Display Information - .NET MAUI | Microsoft Learn


In your Activity1.cs:

using Android.Util;

DisplayMetrics metrics = new DisplayMetrics();
float DisplayDotsPerInchX = metrics.Xdpi;
float DisplayDotsPerInchY = metrics.Ydpi;