简体   繁体   中英

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). But when I run the game on my android phone it still installs with the default libgdx icon and not my own icon. 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? I deleted those icons and replaced them. I also invalidated my intellij caches and restarted.

If you look in your android/res folder, you'll see 5 different directories starting with 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. This is why by default, you'll find this in your manifest: @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 . Make your icon and click the download link. Open the ZIP file, and extract it to your res folder.

res文件夹2

You can delete the drawable folders. Go into your manifest, and set your icon to: @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 will make all different images for you

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)

Android API 26 introduced adaptive icons:

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

libGDX provides new files that handle this. Use the libGDX setup wizard to generate a blank project to see it. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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