首页 > 解决方案 > 如何在strings.xml中居中字符串?

问题描述

我有一个文本字符串,我想在我的应用程序中居中。这是strings.xml这样的:

<resources>
    <string name="app_name"><font size="28" fgcolor='#444444'><b>Test</b></font></string>
</resources>

我怎样才能使这个文本居中?目前它在应用程序的 header中左对齐

这是使用字符串的地方(in AndroidManifest.xml):

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.Blue">

我试过android:gravity="center"了,但这似乎只适用于 TextViews... 这不是 TextView,这是应用程序的标题栏。

标签: xmlstringandroid-studio

解决方案


推荐阅读