简体   繁体   中英

How to add app icon for cordova android project

I added these lines to my config.xml and added the png files with those resolutions and paths to my project root and run the compile...

   <platform name="android">
        <!--
            ldpi    : 36x36 px
            mdpi    : 48x48 px
            hdpi    : 72x72 px
            xhdpi   : 96x96 px
            xxhdpi  : 144x144 px
            xxxhdpi : 192x192 px
        -->
        <icon src="res/android/ldpi.png" density="ldpi" />
        <icon src="res/android/mdpi.png" density="mdpi" />
        <icon src="res/android/hdpi.png" density="hdpi" />
        <icon src="res/android/xhdpi.png" density="xhdpi" />
        <icon src="res/android/xxhdpi.png" density="xxhdpi" />
        <icon src="res/android/xxxhdpi.png" density="xxxhdpi" />
    </platform>

but the only thing that happens when I run the compile is that subdirectories get added to my res/ directory (see below)... but not to other places in the project. The other places in the project still only have the default logo icon. So I only get the default icon for my apk.

res/android
res/mipmap-hdpi/icon.png
res/mipmap-ldpi/icon.png
res/mipmap-mdpi/icon.png
res/mipmap-xhdpi/icon.png
res/mipmap-xxhdpi/icon.png
res/mipmap-xxxhdpi/icon.png

This is part my config.xml file.

<platform name="android">
        <!-- you can use any density that exists in the Android project -->
        <icon src="www/res/icon/android/icon-36-ldpi.png" density="ldpi" />
        <icon src="www/res/icon/android/icon-48-mdpi.png" density="mdpi" />
        <icon src="www/res/icon/android/icon-72-hdpi.png" density="hdpi" />
        <icon src="www/res/icon/android/icon-96-xhdpi.png" density="xhdpi" />

        <splash src="www/res/screen/android/screen-ldpi-portrait.png" density="port-hdpi"/>
        <splash src="www/res/screen/android/screen-ldpi-portrait.png" density="port-ldpi"/>
        <splash src="www/res/screen/android/screen-mdpi-portrait.png" density="port-mdpi"/>
        <splash src="www/res/screen/android/screen-xhdpi-portrait.png" density="port-xhdpi"/>
        <splash src="www/res/screen/android/screen-ldpi-landscape.png" density="land-hdpi"/>
        <splash src="www/res/screen/android/screen-ldpi-landscape.png" density="land-ldpi"/>
        <splash src="www/res/screen/android/screen-mdpi-landscape.png" density="land-mdpi"/>
        <splash src="www/res/screen/android/screen-xhdpi-landscape.png" density="land-xhdpi"/>
    </platform>

All files are placed in right position.

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