- 首先找到 toolbar 所在xml布局文件,將toolbar控件放置在一個相對布局(RelativeLayout)中,然后設置 toolbar 的 title 為空(在 title 屬性欄中隨便打幾個空格即可);
- 然后在 toolbar 所在的相對布局中加入 TextView 控件,將其 Text 設置為想要的標題;
- 並將該 TextView 控件設置水平居中以及垂直居即可(即設置 layout_centerHorizontal 和 layout_centerVertical);
- 最后根據實際需要在 TextView 控件中設置字體樣式。
- 在Toolbar中設置左偏移屬性值為0即: app:contentInsetStart="0dp"