Xamarin Android获取以px为单位的屏幕尺寸

时间:2018-11-24 06:08:35

标签: xamarin

嗨,我正在尝试获取设备的屏幕尺寸 我已经试过这段代码:     layout.Width;     layout.Height; 但宽度和高度返回0,0 有人知道如何获得屏幕尺寸吗?

1 个答案:

答案 0 :(得分:0)

Xamarin“ DetectScreenSize”配方:

> PCA1$map[[1]]
class       : RasterLayer 
dimensions  : 1352, 3570, 4826640  (nrow, ncol, ncell)
resolution  : 0.1, 0.1  (x, y)
extent      : -177, 180, -56.07567, 79.12433  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 
data source : /private/var/folders/3c/tsrm9qxs7t323jrz5k8h4d600000gn/T/RtmpKORCX5/raster/r_tmp_2018-11-17_002746_40497_32387.grd 
names       : PC1 
values      : -3.131791, 3.387701  (min, max)

re:https://github.com/xamarin/recipes/blob/master/Recipes/android/resources/device_specific/detect_screen_size/DetectScreenSize/Activity1.cs