Search code examples
android-support-libraryandroid-coordinatorlayoutandroid-collapsingtoolbarlayoutandroid-appbarlayout

Toolbar text size in Android Support Library 22.2.1 vs 22.2.0


Yet another question based on Chris Banes's cheesesquare demo.

After updating to the latest release of the library, I couldn't help notice an outstanding difference in the toolbar text size, when it is not collapsed.

Previous release, 22.2.0: design support library 22.2.0 Current release, 22.2.1: design support library 22.2.1

What's the reason for such an increase and most importantly how do I override it?

Is it easily achievable to set the desired size by using an xml attribute, or does a specific style need to be defined & used?

Note

Whichever the solution is, it shall not affect the size of the text when the toolbar is collapsed. Only when it is expanded, like in the above screenshots.


Solution

  • You need to define a custom style for CollapsingToolbarLayout:

    <style name="CustomToolbar">
        <item name="android:textSize">@dimen/expanded_title_size</item>
    </style>
    

    And then apply it using setExpandedTitleTextAppearance method:

    myCollapsingToolbar.setExpandedTitleTextAppearance(R.style.CustomToolbar);