Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to center the title of a CollapsingToolbarLayout?

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

like image 254
Javed Khatri Avatar asked Jun 15 '15 13:06

Javed Khatri


2 Answers

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"
like image 72
androholic Avatar answered Nov 06 '22 22:11

androholic


In my use case, I set app:titleEnabled to false, I didn't need it anyway. After that, my gravity was respected properly inside the Toolbar layout.

like image 22
Nguyễn Hoàng Anh Avatar answered Nov 06 '22 21:11

Nguyễn Hoàng Anh