Android 启动器图标不起作用

发布于 2024-12-06 12:46:50 字数 423 浏览 2 评论 0原文

我目前正在开发一个 Android 应用程序。我创建了图标 (.png) 并将它们放置在 /res/drawable-hdpi (以及 ldpi 和 mdpi)文件夹中。在我的清单中,

<application android:icon="@+drawable/icon" android:label="@string/app_name">

我的图标全部命名为 icon.png。

我已经编译了源代码,当我在模拟器上运行它时,该图标会显示在桌面启动器中。但是,当我将 apk 复制到实际手机时,桌面启动器显示默认包图标,而不是我的自定义图标。不过,有趣的是,当我实际安装应用程序时,包管理器确实显示了该图标。但安装后,图标不显示。

如何使我的应用程序图标显示为启动器图标?

跳过

I have an Android app that I am currently developing. I have created icons (.png) and placed them in the /res/drawable-hdpi (and ldpi & mdpi) folders. In my manifest I have

<application android:icon="@+drawable/icon" android:label="@string/app_name">

my icons are all named icon.png.

I have compiled the source and when I run it on the emulator, the icon shows up in the desktop launcher. But when I copy the apk to my actual phone, the desktop launcher shows the default package icon rather than my custom icon. Although, funny enough when I am actually installing the app, the package manager does show the icon. But once it is installed, the icon does not show.

How do I make my application icon show up as the launcher icon?

Skip

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

糖果控 2024-12-13 12:46:50

删除“@+drawable/icon”中的“+”

remove the "+" in "@+drawable/icon"

倾城泪 2024-12-13 12:46:50

我遇到了同样的问题,并且我从未在清单中使用“+”。
重新启动并擦除模拟器或重新启动 Eclipse 对我来说不起作用。

我只是解决了将所有 icon.png 文件重命名为不同的文件(例如 iconq.png)的问题。

I had the same problem, and I never used the "+" in the manifest.
Rebooting&wiping emulator or restarting Eclipse did not work for me.

I simply solved renaming all the icon.png files to something different (e.g. iconq.png).

乜一 2024-12-13 12:46:50

我刚刚遇到了同样的问题。我将图标重命名为 launch_icon 并重新启动 Eclipse。不确定是哪一个成功了,但之后就成功了

I just had the same issue. I renamed my icon to launch_icon and restarted Eclipse. Not sure which one did the trick but it worked after that

幸福丶如此 2024-12-13 12:46:50

可以为不同的组件(即活动和服务)设置不同的图标。确保您只为应用程序元素定义了图标,没有其他任何内容。这将保证所有组件都具有相同的图标,即应用程序中定义的图标。

It's possible to have different icons set for different components (ie Activity and Service). Make sure that you have the icon only defined for the application element, and nothing else. This will guarantee that all components will have a the same icon, the one defined in the application.

薄荷→糖丶微凉 2024-12-13 12:46:50

由于某种原因,它是我手机上的 ROM(它是姜饼 MIUI ROM)。我今天在手机上安装了新的 ROM,运行良好。奇怪的。

For some reason it was the ROM I had on my phone (it was a gingerbread MIUI ROM). I put a new ROM on my phone today and it works fine. Strange.

隐诗 2024-12-13 12:46:50

我有类似的问题。我正在运行自定义 rom (Cyanogen mod 7),我的解决方案是简单地重新启动我的设备。之后,图标出现了。

I had a similar problem. I am running a custom rom (Cyanogen mod 7), and my solution was to simply reboot my device. After that, the icon appeared.

要走干脆点 2024-12-13 12:46:50

确保您的启动器 Activity 的 Intent 名为 MAIN
即,

<intent-filter>
            <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

此外,将图标添加到您的Drawable文件夹中,然后在Manifest的应用程序块中引用它。

<application
    android:allowBackup="true"
    android:icon="@drawable/icon"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

Make sure that the Intent of your Launcher Activity is named MAIN
i.e,

<intent-filter>
            <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

Moreover, add the icon to your Drawable folders and then refer it in the application block of Manifest.

<application
    android:allowBackup="true"
    android:icon="@drawable/icon"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
独自唱情﹋歌 2024-12-13 12:46:50

就我而言,我在装有 Android Nougat 的 Nexus 5X 设备中进行测试,图标是正确的,但在同一 Android 版本但使用 Pixel Launcher 的模拟器中,显示了默认图标。
我发现在我的例子中,我忘记替换清单中的 android:roundIcon 属性以使用新属性。

圆形图标资源

应用程序现在可以定义圆形启动器图标,这些图标在支持它们的设备上使用。当启动器请求应用程序图标时,框架会返回 android:icon 或 android:roundIcon,具体取决于设备构建配置。因此,应用程序应确保定义 android:icon 和 android:roundIcon 资源响应启动器意图时。您可以使用Image Asset Studio设计圆形图标。

您应该确保在支持新版本的设备上测试您的应用
圆形图标,查看圆形应用程序图标的外观及其效果
显示。测试资源的一种方法是运行 Android
模拟器并使用针对 API 级别 25 的 Google API 模拟器系统。
您还可以通过在 Google Pixel 上安装您的应用来测试您的图标
设备。

有关设计应用程序启动器图标的更多信息,请参阅
材料设计指南。

https://developer.android.com/about/版本/nougat/android-7.1.html#circular-icons

In my case, I was testing in a Nexus 5X device with the Android Nougat and the icon was correct, but in the emulator on the same android version but with the Pixel Launcher, the default icon were shown.
I saw that in my case I forgot to replace the android:roundIcon property in the manifest to use the new one.

Round Icon Resources

Apps can now define circular launcher icons, which are used on devices that support them. When a launcher requests an app icon, the framework returns either android:icon or android:roundIcon, depending on the device build configuration. Because of this, apps should make sure to define both android:icon and android:roundIcon resources when responding to launcher intents. You can use Image Asset Studio to design round icons.

You should make sure to test your app on devices that support the new
circular icons, to see how your circular app icons look and how they
are displayed. One way to test your resources is to run the Android
emulator and use a Google APIs Emulator System targeting API level 25.
You can also test your icons by installing your app on a Google Pixel
device.

For more information about designing app launcher icons, see the
Material Design guidelines.

https://developer.android.com/about/versions/nougat/android-7.1.html#circular-icons

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文