i'm trying to set i Custom Toolbar Title from here : Android toolbar center title and custom font
But title is still appear like below picture :
Here is Toolbar XML :
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay">
<TextView
android:id="@+id/toolbar_title"
android:textColor="#FFF"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:layout_gravity="center" />
</android.support.v7.widget.Toolbar>
JAVA :
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
TextView mTitle = (TextView) toolbar.findViewById(R.id.toolbar_title);
/*Start Font Face*/
Typeface tf = Typeface.createFromAsset(getAssets(), "Limelight.ttf");
mTitle.setTypeface(tf);
/*Rnd Font Face */
setSupportActionBar(toolbar);
mTitle.setText(toolbar.getTitle());
Use getSupportActionBar().setTitle("")
to hide default title
.
Try this:
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle("");
TextView mTitle = (TextView) toolbar.findViewById(R.id.toolbar_title);
Typeface tf = Typeface.createFromAsset(getAssets(), "Limelight.ttf");
mTitle.setTypeface(tf);
mTitle.setText("ARTISTIC");