Skip to content

Instantly share code, notes, and snippets.

@PsyGik
Forked from laaptu/GetActionBarHeight
Last active September 21, 2015 05:31
Show Gist options
  • Save PsyGik/250ae333b90eb23a9fbd to your computer and use it in GitHub Desktop.
Save PsyGik/250ae333b90eb23a9fbd to your computer and use it in GitHub Desktop.
Android getting ActionBar Height in dip
public int getActionBarHeight() {
int actionBarHeight = 0;
TypedValue tv = new TypedValue();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv,
true))
actionBarHeight = TypedValue.complexToDimensionPixelSize(
tv.data, getResources().getDisplayMetrics());
} else {
actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data,
getResources().getDisplayMetrics());
}
return actionBarHeight;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment