Android设备获取状态栏高度的正确姿势
int height = 0;
int resourceId = getApplicationContext().getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
height = getApplicationContext().getResources().getDimensionPixelSize(resourceId);
}
使用:在onCreate()方法中调用,与setonContentView()前后顺序无关。