I'm trying to figure out the right way to use a custom font for the toolbar title, and center it in the toolbar (client requirement).
At the moment, i'm using the good old ActionBar, and I was setting the title to empty value, and using setCustomView
to put my custom font TextView and center it using ActionBar.LayoutParams.
Is there a better way to do that? Using the new Toolbar as my ActionBar.
Best Answer
To use a custom title in your
Toolbar
all you need to do is remember is thatToolbar
is just a fancy ViewGroup so you can add a custom title like so:This means that you can style the
TextView
however you would like because it's just a regularTextView
. So in your activity you can access the title like so: