Toolbar subtitle is cut (It does not fit in height)

I had used layout_height=actionBarSize for a long time even with subtitles present and never came across this issue (testing on various emulators and pixel phone). I applied this fix now after seeing my subtitle being cut-off on a Samsung Galaxy phone. Seems to me that this issue depends on how the system sets up the subtitle spacing.

I already had switched to the new material components (androidx). So the issue is still present in latest version.

Using the solution of a combination of wrap_content as height and the actionBarSize attribute as minHeight doesn't affect devices without the issue, so on those, no jumping will be visible.

<androidx.appcompat.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="?android:actionBarSize" />

i suggest you to create a new layout for toolbar and then you can fill it however you want to.And set it as ActionBar in java code. Therefore, you will not face any space problem anymore.


I have used a toolbar with subtitles and as well as using a layout_height="wrap_content" I also add a minHeight. This will ensure your toolbar is at least the minimum height. I've not seen it jump in height or crop but I always have a subtitle set.

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