Skip to content

Instantly share code, notes, and snippets.

@Hackforid
Created December 29, 2013 10:29
Show Gist options
  • Save Hackforid/8169153 to your computer and use it in GitHub Desktop.
Save Hackforid/8169153 to your computer and use it in GitHub Desktop.
private int getActionBarHeight() {
int actionBarHeight = getSupportActionBar().getHeight();
if (actionBarHeight != 0)
return actionBarHeight;
final 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 if (getTheme().resolveAttribute(com.actionbarsherlock.R.attr.actionBarSize, tv, true))
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