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 ActionBar
; but it has a different height.
kToolbarHeight top-level constant Null safetyThe height of the toolbar component of the AppBar.
By default, the image size is set to the dimensions of 16 by 15 pixels. All buttons are the same width, by default 24 by 22 pixels. A toolbar's height is determined by the height of the buttons, and a toolbar's width is the same as the width of the parent window's client area, also by default.
You can set the height here android:minHeight="? attr/actionBarSize" in your XML. Use height and not minHeight.
View above the Toolbar is officially know as status bar in android and to change color of status bar check out the answer of this question How to change the status bar color in android.
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
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With