Search code examples
androidtoolbartext-size

How to change the toolbar text size?


I want to change the size of text in Toolbar. Because in my application, Toolbar text has different sizes both for landscape and portrait mode.

Is it possible to change the text size of text in Toolbar?


Solution

  • Use app:titleTextAppearance:

    <android.support.v7.widget.Toolbar
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="?actionBarSize"
        android:id="@+id/toolbar"
        app:titleTextAppearance="@style/Toolbar.TitleText" />
    

    and override the default title size in a custom style:

    <style name="Toolbar.TitleText" parent="TextAppearance.Widget.AppCompat.Toolbar.Title">
        <item name="android:textSize">18sp</item>
    </style>
    

    Result:

    Screenshot