gpt4 book ai didi

android - 工具栏上的标题文本对齐

转载 作者:行者123 更新时间:2023-12-05 00:22:10 25 4
gpt4 key购买 nike

我在我的项目中使用支持库中的工具栏。而且我找不到如何更改文本对齐方式。默认在左侧。但我需要把它移到中心。我认为有一个方法 setTitleTextAppearance() ,但我不明白它的使用。

最佳答案

添加您自己的TextView可以在任何你想要的地方对齐:

<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/green">

<!-- Below will add your text in the center of the toolbar -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Your Text"
android:textColor="#ff0000"
android:textStyle="bold"/>

</android.support.v7.widget.Toolbar>

关于android - 工具栏上的标题文本对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27055555/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com