Skip to content

Instantly share code, notes, and snippets.

@dmitriy-chernysh
Last active August 29, 2015 14:24
Show Gist options
  • Save dmitriy-chernysh/6bcfbc917829fc35415b to your computer and use it in GitHub Desktop.
Save dmitriy-chernysh/6bcfbc917829fc35415b to your computer and use it in GitHub Desktop.
Android getting ActionBar height
/**
* Method for getting height of Actionbar
* @param context Application context
* @return height
*/
public static int getActionBarHeight(Context context){
TypedValue tv = new TypedValue();
if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true))
{
return TypedValue.complexToDimensionPixelOffset(tv.data, context.getResources().getDisplayMetrics());
} else {
return 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment