简体   繁体   English

未应用 Libgdx android 图标

[英]Libgdx android icon not being applied

I made a game and now I want to change the icon, so I replaced the icons on res/drawable (with the same file name).我做了一个游戏,现在我想更改图标,所以我替换了 res/drawable 上的图标(使用相同的文件名)。 But when I run the game on my android phone it still installs with the default libgdx icon and not my own icon.但是当我在我的 android 手机上运行游戏时,它仍然使用默认的 libgdx 图标安装,而不是我自己的图标。 Then I tried to change the icon names and also making changes in my manifest file.然后我尝试更改图标名称并在我的清单文件中进行更改。

<application
        android:allowBackup="true"
        android:icon="@drawable/loh_icon" //loh_icon.png is my icon name
        android:label="@string/app_name"
        android:theme="@style/GdxTheme" >

Still the same problem, how can my game still have the default libgdx icon?还是同样的问题,我的游戏怎么还有默认的libgdx图标? I deleted those icons and replaced them.我删除了这些图标并替换了它们。 I also invalidated my intellij caches and restarted.我也使我的 Intellij 缓存无效并重新启动。

If you look in your android/res folder, you'll see 5 different directories starting with drawable .如果你查看你的android/res文件夹,你会看到 5 个不同的目录,以drawable开头。 The part after the dash is the screen density.破折号后面的部分是屏幕密度。

res文件夹

Inside each folder there is a file called ic_launcher.png with a size for each screen density.每个文件夹内都有一个名为ic_launcher.png的文件,其大小适用于每个屏幕密度。 This is why by default, you'll find this in your manifest: @drawable/ic_launcher .这就是为什么默认情况下,您会在清单中找到它: @drawable/ic_launcher You'll need to make different resolutions for different densities, and replace them.您需要为不同的密度制作不同的分辨率,并替换它们。

You can use this online tool to automatically do it for you: Android Asset Studio .您可以使用这个在线工具自动为您完成: Android Asset Studio Make your icon and click the download link.制作您的图标并单击下载链接。 Open the ZIP file, and extract it to your res folder.打开 ZIP 文件,并将其解压缩到您的res文件夹中。

res文件夹2

You can delete the drawable folders.您可以删除可绘制文件夹。 Go into your manifest, and set your icon to: @mipmap/ic_launcher进入您的清单,并将您的图标设置为: @mipmap/ic_launcher

In Android Studio just right click over android/res -> new/image asset, on dialog choose icon_laucher and the radiobox for image, there you can select whichever image you want.在 Android Studio 中,只需右键单击 android/res -> new/image 资产,在对话框中选择 icon_laucher 和图像的单选框,您可以在那里选择您想要的任何图像。 Android will make all different images for you Android 将为您制作所有不同的图像

Some phones will cache app icons.有些手机会缓存应用程序图标。 This means that it might keep showing you the old app icon even after you change it.这意味着即使您更改旧应用程序图标,它也可能会继续向您显示旧应用程序图标。

Try restarting the phone.尝试重启手机。 Alternatively, you can try changing the theme of the phone if it has such an option (eg: MIUI)或者,如果手机有这样的选项,您可以尝试更改手机的主题(例如:MIUI)

Android API 26 introduced adaptive icons: Android API 26 引入了自适应图标:

https://developer.android.com/guide/practices/ui_guidelines/icon_design_adaptive https://developer.android.com/guide/practices/ui_guidelines/icon_design_adaptive

libGDX provides new files that handle this. libGDX 提供了处理此问题的新文件。 Use the libGDX setup wizard to generate a blank project to see it.使用 libGDX 设置向导生成一个空白项目来查看它。 The files are stored in:文件存储在:

android/res/drawable-apydpi-v26

You can edit ic_launcher_foreground.xml and ic_launcher.xml to set it up for API 26+ devices.您可以编辑 ic_launcher_foreground.xml 和 ic_launcher.xml 以针对 API 26+ 设备进行设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM