A screenshot of my activity preview
我是 android studio 的新手,一直在关注各种在线教程。找不到这个问题的答案。如果我更改 strings.xml 中的 app_name,上面发布的图片上的名称也会更改,如果我生成 apk,它也充当应用程序名称。我尝试在 strings.xml 中添加另一个字符串,但没有任何变化。有没有办法编辑上面的标题而不更改最终的应用程序名称
strings.xml代码
<resources>
<string name="app_name">Hello world</string>
最佳答案
这是因为在图像显示的布局和 list 文件中都使用了相同的字符串。
您可能会在 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/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
请注意 android:label="@string/app_name"
部分。这是您的应用程序将显示为应用程序名称的字符串。
因此,如果您想使用两个不同的名称,一个用于应用程序名称,一个用于布局内部,只需创建两个不同的字符串并将一个分配给 AndroidManifest.xml,另一个分配给您图像显示的布局。
关于java - 如何更改应用程序头部的副标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51343397/