Skip to content

Instantly share code, notes, and snippets.

@marvinlix
Created May 7, 2012 12:45
Show Gist options
  • Select an option

  • Save marvinlix/2627562 to your computer and use it in GitHub Desktop.

Select an option

Save marvinlix/2627562 to your computer and use it in GitHub Desktop.
get statusbar height
Class<?> c = null;
Object obj = null;
Field field = null;
int x = 0, sbar = 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());
sbar = getResources().getDimensionPixelSize(x);
} catch (Exception e1) {
loge("get status bar height fail");
e1.printStackTrace();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment