In addition to @vedant1811 answer, you can programmatically obtain actionBarSize from attrs:
TypedValue tv = new TypedValue();
if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true))
{
actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, context.getResources().getDisplayMetrics());
}
you can use the toolbar widget that already exist in android and put the height wrap_content , so it will better to get the default size that come with it.