如何在中心设置工具栏标题和副标题



就我而言,我想在中心设置工具栏标题和副标题。我已经有一个解决方案可以在工具栏中设置自定义布局。是否有任何其他解决方案可以在不使用自定义布局的情况下设置工具栏标题和副标题?

解决方案 1:

<android.support.v7.widget.Toolbar
    android:id="@+id/custom_toolbar"
    android:layout_width="match_parent"
    android:layout_height="?android:attr/actionBarSize"
    android:background="@android:color/holo_red_dark">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="abc"
        android:textColor="@android:color/white"
        android:textSize="20sp"
        android:layout_marginRight="?android:attr/actionBarSize"
        android:gravity="center"/>
    </android.support.v7.widget.Toolbar>

我不想使用自定义布局来设置工具栏标题和副标题。我提前感谢您的努力。

<android.support.v7.widget.Toolbar
    android:id="@+id/custom_toolbar"
    android:layout_width="match_parent"
    android:layout_height="?android:attr/actionBarSize"
    android:background="@android:color/holo_red_dark">        
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="abc"
        android:textColor="@android:color/white"
        android:textSize="20sp"
        android:layout_marginRight="?android:attr/actionBarSize"
        android:gravity="center"/>
</android.support.v7.widget.Toolbar>

最新更新