页面初始化的时候调用,statusHeight 即为状态栏的高度
Rect localRect = new Rect();
getWindow().getDecorView().getWindowVisibleDisplayFrame(localRect);
statusHeight = localRect.top;
if (0 == statusHeight) {
Class<?> localClass;
try {
localClass = Class.forName("com.android.internal.R$dimen");
Object localObject = null;
int intenger = 0;
localObject = localClass.newInstance();
intenger = Integer.parseInt(localClass
.getField("status_bar_height").get(localObject)
.toString());
statusHeight = this.getResources().getDimensionPixelSize(
intenger);
} catch (Exception e) {
e.printStackTrace();
}
}