Physical dimensions Iphone XS Max and Iphone XR screens

Viewed 8102

With the update of the Apple product line, I updated the software and tried to find out the physical size of the screens of the new devices in pixels.

With the iPhone XS it's clear:

  • the width / height is 1125 / 2436 pix,
  • ScalingFactor 3,
  • physically it's 375 / 812 points in width / height (like Iphone X).

With the iPhone XR is also clear:

  • the width / height of 750 / 1624 pix,
  • ScalingFactor 2,
  • physically also produces 375 / 812 points in height / width.

But it's not clear with the iPhone XS Max

  • Apple indicates a width / height of 1242 / 2688 pixels,

but my calculations give data like the iPhone XS:

  • width / height 1125 / 2436 pix,
  • ScalingFactor 3,
  • physically get 375/ 812 width / height points.

I think with Device.Info.PixelScreenSize.Height and Device.Info.PixelScreenSize.Width, I divide into Device.Info.ScalingFactor, then I recheck Xamarin.Essentials, namely DeviceDisplay.ScreenMetrics, then I also divide it into Device.Info.ScalingFactor.

Where is the truth? What to take for reliable data?

P.S. Sorry for Google Translate

EDIT: 1. App.cs

 public partial class App : Application
        {
            public static int ScreenWidth;
            public static int ScreenHeight;
            public static Size ScreenSize;
            ...

2. AppDelegate.cs

 public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            App.ScreenWidth = (int)UIScreen.MainScreen.Bounds.Width;
            App.ScreenHeight = (int)UIScreen.MainScreen.Bounds.Height;
            App.ScreenSize = new Size(UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height);
            ...

3. MainPageViewModel.cs

public class MainPageViewModel
    {
        public double DeviceHeightInPixels { get; set; }
        public double DeviceWidthPixels { get; set; }
        public double Coefficient { get; set; }
        public double PhysicalHeightInPixels { get; set; }
        public double PhysicalWidthInPixels { get; set; }
        public double DeviceHeightInPixelsFromMetrics { get; set; }
        public double DeviceWidthPixelsFromMetrics { get; set; }
        public int AppScreenHeight { get; set; }
        public int AppScreenWidth { get; set; }
        public double AppScreenSizeHight { get; set;}
        public double AppScreenSizeWidth { get; set; }

        public MainPageViewModel()
        {
            var metrics = DeviceDisplay.ScreenMetrics;

            DeviceHeightInPixels = Device.Info.PixelScreenSize.Height;
            DeviceWidthPixels = Device.Info.PixelScreenSize.Width;

            Coefficient = Device.Info.ScalingFactor;

            PhysicalHeightInPixels = DeviceHeightInPixels / Coefficient;
            PhysicalWidthInPixels = DeviceWidthPixels / Coefficient;

            DeviceHeightInPixelsFromMetrics = metrics.Height;
            DeviceWidthPixelsFromMetrics = metrics.Width;

            AppScreenHeight = App.ScreenHeight;
            AppScreenWidth = App.ScreenWidth;

            AppScreenSizeHight = App.ScreenSize.Height;
            AppScreenSizeWidth = App.ScreenSize.Width;
        }
    }

enter image description here

2 Answers

EDIT :

I think you have wrong simulator selected. The XS Max does give correct values as per your expectation. Heres a simple swift code (check nativeBounds for actual size) :

    print("Name:\t\(UIDevice.current.name)")
    print("Size:\t\(UIScreen.main.bounds.size)")
    print("Scale:\t\(UIScreen.main.scale)")
    print("Native:\t\(UIScreen.main.nativeBounds.size)")

And heres the output from all four X simulators

Name:   iPhone X
Size:   (375.0, 812.0)
Scale:  3.0
Native: (1125.0, 2436.0)

Name:   iPhone XR
Size:   (414.0, 896.0)
Scale:  2.0
Native: (828.0, 1792.0)

Name:   iPhone XS
Size:   (375.0, 812.0)
Scale:  3.0
Native: (1125.0, 2436.0)

Name:   iPhone XS Max
Size:   (414.0, 896.0)
Scale:  3.0
Native: (1242.0, 2688.0)

Original answer :

DeviceDisplay.ScreenMetrics in Xamarin.Essentials, is a simple bounds * scale calculation. (Ref : source code)

Scale documentation clearly states :

The default logical coordinate space is measured using points.

You can see from resolutions reference, that Points measurement for XS max and XR is exactly the same (although theres difference in pixel measurement).

This is what apple intends us to use for simplicity and avoid android like fragmentation in code (but theres 3 sizes already .. hmmph).

In conclusion, for any app / code related discussion, just refer to the points (i.e. scale factor) and forget physical dimensions and pixels.

The question is settled. In fact, the XCode 10.0 simulator when you start the application from the Resources folder takes the most appropriate image and by its size builds the screen size of the simulator, and since the projects created earlier, there are no images for the new phone sizes, it takes the largest (that is, for the Iphone X). It is required to correct this.

Related