You can have a custom TextView
in the toolbar like this:
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_top"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="@color/action_bar_bkgnd"
app:theme="@style/ToolBarTheme" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title"
android:layout_gravity="center"
android:id="@+id/toolbar_title" />
</android.support.v7.widget.Toolbar>
So, this will center the text. If you want to add custom font to a normal Toolbar
, make a <style>
:
<style android:name="ToolbarFont">
<item android:fontFamily = "@font/fontName" />
</style>
And add it to the toolbar:
toolbar.setTitleTextAppearance(this, R.style.ToolbarFont);
For the textview in the toolbar, you can define it with the fontFamily
attribute:
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_top"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="@color/action_bar_bkgnd"
app:theme="@style/ToolBarTheme" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title"
android:layout_gravity="center"
android:id="@+id/toolbar_title"
android:fontFamily="@font/fontFamily" />
</android.support.v7.widget.Toolbar>