Android status bar height in Xamarin.Android?

淺唱寂寞╮ 提交于 2019-12-14 02:56:52

问题


I want to find the height of the red square excluding the blue one.


回答1:


To get the height of status bar in your OnCreate method, you can use the following:

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;
}

The variable contentHeight now has the value you are looking for.



来源:https://stackoverflow.com/questions/36927534/android-status-bar-height-in-xamarin-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!