android - 启动器 Activity 和应用程序名称是否可以有不同的标签名称

标签 android

我只是制作一个演示应用程序,我需要为启动器activity和应用程序名称的标签设置不同的文本。

当我将启动器 Activity 标签名称设置为“登录”时,它会显示相同的应用程序名称。是否可以在 list 中手动指定应用程序名称。

这就是 androidmanifest.xml 的外观,但目前它也将 Login 显示为应用程序名称。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example" >

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".LoginActivity"
            android:label="@string/login_screen_title" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

字符串.xml

<string name="app_name">Demo</string>

<!-- login screens strings -->
<string name="login_screen_title">LOGIN</string>

提前致谢。

最佳答案

启动器 Activity 标签完全有可能与应用程序名称不同,您的代码似乎是正确的,但奇怪的是它不适合您,请尝试为 Intent 过滤器设置标签

 <intent-filter android:label="koko">

我在下面引用了android文档中的一段话,解释了如何处理标签

In every case, the icon and label set in a containing element become the default icon and label settings for all of the container's subelements. Thus, the icon and label set in the element are the default icon and label for each of the application's components. Similarly, the icon and label set for a component — for example, an element — are the default settings for each of the component's elements. If an element sets a label, but an activity and its intent filter do not, the application label is treated as the label for both the activity and the intent filter.

来源http://developer.android.com/guide/topics/manifest/manifest-intro.html#iconlabel

关于android - 启动器 Activity 和应用程序名称是否可以有不同的标签名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25872778/

相关文章:

android - Android 中的边距

java - 搜索栏过滤 ListView 项目

android - 循环约束和 "missing constraints"错误

android - WebView 的 Firebase 性能监控

Android:在自定义对话框标题中使用默认样式

android - 在 ScrollView 中的相对布局之间动态滚动

android - 如何在 Android 中以编程方式从设备读取 SMS 消息?

android - 如何为 DownloadManager 请求设置图标?

java - Google Geocoding API - 查询中存在非法字符

android - 在 android Jetpack compose 中使用列表处理状态