【问题标题】:How to set toolbar title and subtitle in centre [duplicate]如何在中心设置工具栏标题和副标题[重复]
【发布时间】:2019-08-17 14:09:19
【问题描述】:

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

解决方案 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


    【解决方案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>
    

    【讨论】:

    • 谢谢,但我不想使用自定义布局。
    • 你想在菜单中使用喜欢的项目吗?
    • 不,我必须在中心显示标题和副标题工具栏,而且我还有很多活动和片段。所以我没有使用自定义布局。
    猜你喜欢
    • 1970-01-01
    • 2012-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-30
    • 1970-01-01
    • 1970-01-01
    • 2020-09-27
    相关资源
    最近更新 更多