What is the height of the Android Toolbar
introduced in Lollipop? It\'s a quite simple question but I haven\'t found an answer here except for the ActionB
Call this method to get the value programmatically:
public int getToolBarHeight() {
int[] attrs = new int[] {R.attr.actionBarSize};
TypedArray ta = getContext().obtainStyledAttributes(attrs);
int toolBarHeight = ta.getDimensionPixelSize(0, -1);
ta.recycle();
return toolBarHeight;
}
The Toolbar
(if not extended) has the height of:
56dp
(default)48dp
(landscape)64dp
(sw600dp; i.e. tablet)The Toolbar
is higher than the pre-lollipop ActionBar
; it was 48dp
by default, 40dp
in landscape and 56dp
in sw600dp.
And to retrieve the height of the Toolbar in XML, just use
?android:attr/actionBarSize
or if you're using the AppCompat library this
?attr/actionBarSize