首页 > 解决方案 > Activity android:label 更改应用程序名称

问题描述

我开始了一个没有活动的新项目,然后我创建了自己的项目并将它们注册为如下所示。但是每当我在我的 LoginActivity 上放置一个标签时,它就会改变应用程序名称。

<application
    android:name=".app.ApplicationController"
    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=".activities.LoginActivity"
        android:label="@string/login_screen_label"
        android:launchMode="singleTop"
        android:windowSoftInputMode="adjustPan">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".activities.RegisterActivity"
        android:launchMode="singleTop"
        android:windowSoftInputMode="adjustPan" />
    <activity
        android:name=".activities.MainActivity"
        android:launchMode="singleTop"/>

</application>

还有我的字符串资源

<string name="app_name">My ToDo</string>
<string name="login_screen_label">Log in</string>

我究竟做错了什么

更新actitity_login.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="0dp" >

</RelativeLayout>

标签: javaandroidxmlmanifest

解决方案


添加标签android:label="app name"_application

使用android:labelinapplication标签将设置应用程序名称。并且使用android:labelinActivity标签将设置Activity.


推荐阅读