1. 程式人生 > >【Android開發】Toolbar與標題居中

【Android開發】Toolbar與標題居中

在toolbar的xml佈局部分加一個textview並居中即可(記得不要給toolbar設定標題!)
具體程式碼:

<android.support.v7.widget.Toolbar>
    android:id="@+id/..."
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/..."
    >

    <TextView
        android:layout_width="wrap_content"
android:layout_height="wrap_content" android:gravity="center" android:text="@string/..." android:textSize="@value/..." android:textColor="@color/..." /> </android.support.v7.widget.Toolbar>