要在OnCreate
方法中获取状态栏的高度,可以使用以下命令:
int statusBarHeight = 0, totalHeight = 0, contentHeight = 0;
int resourceId = Resources.GetIdentifier ("status_bar_height", "dimen", "android");
if (resourceId > 0) {
statusBarHeight = Resources.GetDimensionPixelSize (resourceId);
totalHeight = Resources.DisplayMetrics.HeightPixels;
contentHeight = totalHeight - statusBarHeight;
}
变量contentHeight
现在具有您正在寻找的值。