Android – How to center the title of a CollapsingToolbarLayout

androidandroid-collapsingtoolbarlayout

I tried setExpandTitleTextAppearance, but it didn't work. I want to center the expanded title text.

Best Solution

There is an attribute expandedTitleGravity that you can use with the CollapsingToolbarLayout to center the expanded title text. Add this to your CollapsingToolbarLayout:

app:expandedTitleGravity="bottom|center_horizontal"