Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Toolbar minHeight redundant?

I built my Toolbar like in most with minHeight set to actionBarSize:

<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/colorPrimary"
android:minHeight="?actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
</android.support.v7.widget.Toolbar>

However, if I delete this attribute, there is no difference at all. The Toolbar keeps its actionBarSize, even if I remove the menu and set the app name to an empty String, so there is nothing displayed in the Toolbar at all.

Is there anything I'm missing here?

like image 692
Florian Walther Avatar asked Dec 19 '17 13:12

Florian Walther


1 Answers

android:minHeight="?attr/actionBarSize"

minHeight will ensure that your toolbar does not resize itself lower than ?attr/actionBarSize not matter how small the content inside the toolbar is.

EDIT

If there is nothing inside a toolbar and if minHeight is not set, the toolbar will have a default height of 56dp which is equal to ?attr/actionBarSize

So setting minHeight for toolbar is redundant

For more details, What's the height of the Android Toolbar?

like image 66
Yousaf Avatar answered Sep 27 '22 19:09

Yousaf