private void getStatusBarHeight() {
Class<?> c = null;
Object obj = null;
Field field = null;
int x = 0;
try {
c = Class.forName("com.android.internal.R$dimen");
obj = c.newInstance();
field = c.getField("status_bar_height");
DisplayMetrics dm = new DisplayMetrics();
} catch (Exception e) {
e.printStackTrace();
}
}
Class<?> c = null;
Object obj = null;
Field field = null;
int x = 0;
try {
c = Class.forName("com.android.internal.R$dimen");
obj = c.newInstance();
field = c.getField("status_bar_height");
x = Integer.parseInt(field.get(obj).toString());
/*状态栏高度*/
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
/*屏幕高度*/
} catch (Exception e) {
e.printStackTrace();
}
}