rol*_*ger 8 android-icons cordova android-studio
我已经在图像资源工具中创建了所有自适应图标,但它没有创建文件ic_launcher_foreground.xml- 这反过来又导致我的构建失败,因为 ic_launcher.xml 和 ic_launcher_round.xml 文件中引用了 foreground.xml 文件。
我已经阅读了许多有关如何解决此问题的线程,但没有一个起作用。
此外,ic_launcher.xml 和 ic_launcher_round.xml 文件都专门引用了这两个文件:
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@mipmap/ic_launcher_foreground" />
Run Code Online (Sandbox Code Playgroud)
该/drawable文件夹是使用 ic_launcher_background.xml 文件创建的,但图像资源工具并未创建文件夹/mipmap- 它看起来正在创建所有其他/mipmap-XYZdpi文件夹和图标。
我提出这个问题是因为很多其他线程显示 ic_launcher.xml 和 ic_launcher_round.xml 文件引用同一/drawable文件夹中的 background.xml 和 foreground.xml 文件,这与上面我的不同。
在图像资源中:前景选项卡:图层名称:ic_launcher_foreground 资源类型:图像路径:/dev/myApp/resources/myCustomIcon.png 背景选项卡:图层名称:ic_launcher_background 资源类型:图像路径:res/drawable/ic_launcher_background.xml
我唯一能让ic_launcher_foreground.xml文件出现在“输出文件”屏幕中的情况是在前台选项卡上选择Asset Type: Clip Art
更新:
我在与我的项目相关的 Android Studio 文件夹深处的文件夹中找到了一个ic_launcher_foreground.xml文件drawable (v24)。我将该文件复制到我的项目res/drawable文件夹中 - 现在,当我的应用程序编译到我的测试设备时,我会得到 Android 半机器人图标。
好吧,我终于明白了这一点。为其他有相同问题的人发布我的答案。
使用图像资产工具 -ic_launcher_foreground.xml仅ic_launcher_background.xml当每种类型(前景选项卡/背景选项卡)资产类型定义为图像类型以外的任何类型时才会生成。PNG/JPG 资源类型不会生成这些 xml 文件。
无论资产类型如何,都会生成ic_launcher.xml和。ic_launcher_round.xml如果资产类型是颜色/艺术/文本,这两个 xml 文件都只是引用其他文件 - 引用将是位于该@drawable/文件夹或该@values/文件夹中的其他 XML 文件。
<background android:drawable="@drawable/ic_launcher_background" /> OR
<background android:drawable="@values/ic_launcher_background" />
//@drawable - is the root of all your drawables folders
// - and references only XML, ie: ie_launcher_background.xml
Run Code Online (Sandbox Code Playgroud)
如果资源类型是图像 (png/jpg),则引用将是任何文件夹中存在的新创建的 png/jpg 文件@mipmap。
<foreground android:drawable="@mipmap/ic_launcher_foreground" />
// @mipmap is simply root of all your mipmap folders
// references actual png files, ie: ic_launcher_foreground.png
Run Code Online (Sandbox Code Playgroud)
最后,如果您使用 Cordova,则需要修改 config.xml 以反映要使用的图标文件:
<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>
// this telling the app to find those two XML files in the mipmap-anydpi-v26 folder
// and those files in turn tell the app to find all the png files in the other "mipmap" folders
// if it were this:
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:icon="@drawable/ic_launcher" android:roundIcon="@drawable/ic_launcher_round" />
</edit-config>
// this telling the app to use the XML files sourced in the drawable folders
// if you used png as foreground and color as background
// ic_launcher.xml/ic_launcher_round.xml would both point to:
// @mipmap/ic_launcher_foreground (ie: png images)
// @drawable/ic_launcher_background (ie: xml files)
Run Code Online (Sandbox Code Playgroud)
我希望这对其他人有帮助,因为我觉得上述所有内容在其他文档中都没有得到很好的解释。
| 归档时间: |
|
| 查看次数: |
12347 次 |
| 最近记录: |