获取 Android 或 iOS 移动设备屏幕的真实物理尺寸? [英] Get real physical size of screen of mobile devices Android or iOS?

查看:43
本文介绍了获取 Android 或 iOS 移动设备屏幕的真实物理尺寸?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解 DPI/PPI 和像素不会真正给出屏幕的真实物理尺寸,只有像扩展显示识别数据 (EDID) 这样的信息才能给出屏幕的真实物理尺寸.我怀疑智能手机或平板电脑在某处嵌入了此类信息.如果是这样,Android或iOS等操作系统是否可以访问此类信息,从而API可以显示英寸或CM的大小?

I understand DPI/PPI and pixels won't really give the real physical size of the screen, and only info like Extended Display Identification Data (EDID) could give real physical size of the screen. I suspect the smart phones or tablets have such info embedded somewhere. If so, do the operating system like Android or iOS could access such info, thus the APIs could reveal the size in inch or CM?

然后如何通过 Xamarin C# 或 JAVA 或 Swift 获取大小?

And then how to get the size through Xamarin C# or JAVA or Swift?

我的应用程序是在移动/平板电脑屏幕上以精确的物理尺寸显示形状,例如标尺.

My application is to display a shape in exact physical size on mobile/tablet screens, for example, a ruler.

推荐答案

调用这个方法获取iOS屏幕大小

To get iOS screen size call this method

var screenSize=UIScreen.MainScreen.Bounds;

Android 设备使用以下代码

For android devices use below code

var metrics = Resources.DisplayMetrics;

这篇关于获取 Android 或 iOS 移动设备屏幕的真实物理尺寸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆