Android Oreo - 如何在 Cordova 中设置自适应图标?

标签 android cordova

只是想知道是否有人能够在 Cordova for Android Oreo 上设置自适应图标?我正在使用 android 6.4.0,我的方形图标缩小以适合圆圈。我只是希望它不缩小。我不在乎圆角是否被剪掉。

最佳答案

警告:请勿使用此答案。现在从 Cordova 9 开始支持开箱即用。请参阅 https://stackoverflow.com/a/55169307/2947592

我按照 https://developer.android.com/studio/write/image-asset-studio.html#create-adaptive 中的描述创建了图标,将它们复制到 res/android 并使用以下配置:

config.xml:

<widget ... xmlns:android="http://schemas.android.com/apk/res/android">
    <platform name="android">
        <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
            <application android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" />
        </edit-config>
        <resource-file src="res/android/drawable/ic_launcher_background.xml" target="app/src/main/res/drawable/ic_launcher_background.xml" />
        <resource-file src="res/android/drawable/ic_launcher_foreground.xml" target="app/src/main/res/drawable/ic_launcher_foreground.xml" />
        <resource-file src="res/android/mipmap-anydpi-v26/ic_launcher.xml" target="app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml" />
        <resource-file src="res/android/mipmap-anydpi-v26/ic_launcher_round.xml" target="app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml" />
        <resource-file src="res/android/mipmap-hdpi/ic_launcher.png" target="app/src/main/res/mipmap-hdpi/ic_launcher.png" />
        <resource-file src="res/android/mipmap-hdpi/ic_launcher_round.png" target="app/src/main/res/mipmap-hdpi/ic_launcher_round.png" />
        <resource-file src="res/android/mipmap-mdpi/ic_launcher.png" target="app/src/main/res/mipmap-mdpi/ic_launcher.png" />
        <resource-file src="res/android/mipmap-mdpi/ic_launcher_round.png" target="app/src/main/res/mipmap-mdpi/ic_launcher_round.png" />
        <resource-file src="res/android/mipmap-xhdpi/ic_launcher.png" target="app/src/main/res/mipmap-xhdpi/ic_launcher.png" />
        <resource-file src="res/android/mipmap-xhdpi/ic_launcher_round.png" target="app/src/main/res/mipmap-xhdpi/ic_launcher_round.png" />
        <resource-file src="res/android/mipmap-xxhdpi/ic_launcher.png" target="app/src/main/res/mipmap-xxhdpi/ic_launcher.png" />
        <resource-file src="res/android/mipmap-xxhdpi/ic_launcher_round.png" target="app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png" />
        <resource-file src="res/android/mipmap-xxxhdpi/ic_launcher.png" target="app/src/main/res/mipmap-xxxhdpi/ic_launcher.png" />
        <resource-file src="res/android/mipmap-xxxhdpi/ic_launcher_round.png" target="app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png" />
    </platform>    
</widget>

关于Android Oreo - 如何在 Cordova 中设置自适应图标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47523610/

相关文章:

android - 如何在运行时更改 LinearLayout 的大小?

java - ORMLite 外国成员(member)更新

android - 如何在 html5、phonegap 和 jQuery 中创建进度条

cordova - Jquery-mobile 和 Phonegap 最佳技术

android - 我如何在不向 android 中的特定号码显示拨号器 Activity 的情况下调用电话?

javascript - 如何在 Javascript 或 Jquery 中设置 "backspace press"事件的监听器?

ios - 如何将文件保存到 iOS 的 Library/NoCloud 文件夹?

cordova - 用户相关设置参数保存在哪里

ios - iPhone X 上的 Ionic 插件 ThemeableBrowser 偏移问题

Android 动画起始位置