记录一下正真可行的获取statusBar高度的方法
感谢评论区的小伙伴,已更新为@_小小鱼1号的版本
public static int getStatusBarHeight(){
Resources resources = Resources.getSystem();
int result = 0;
int resourceId = resources.getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
result = resources.getDimensionPixelSize(resourceId);
}
return result;
}