Apurva Apurva - 3 months ago 11
Android Question

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 mode
and
portrait mode
.

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

Answer

Use 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>

Screenshot