0

I created the new project with Navigation Drawer from Project Template, and i want to set the title of toolbar on center like this from this

Zain
  • 37,492
  • 7
  • 60
  • 84
  • 5
    Does this answer your question? [Android toolbar center title and custom font](https://stackoverflow.com/questions/26533510/android-toolbar-center-title-and-custom-font) – Ronak Sethi Jun 18 '20 at 15:50

1 Answers1

0

Try this

<androidx.appcompat.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="Toolbar Title"
        android:layout_gravity="center"
        android:id="@+id/toolbar_title" />


    </androidx.appcompat.widget.Toolbar>

In your Activity

Toolbar toolbarTop = (Toolbar) findViewById(R.id.toolbar_top);
TextView mTitle = (TextView) toolbarTop.findViewById(R.id.toolbar_title);
mTitle.setText("Home");
Hai Hack
  • 948
  • 13
  • 24