ben*_*rah 31 splash-screen cordova
我目前正在尝试迁移到 Cordova 11 并掌握新的 Splash Screen API,但我发现文档在所有方面并不完全清楚。如果有人能为我指出其中一些内容的方向,我将非常感激。
生成自适应图标的最佳方法是什么?
在 Splash Screen 文档中,它在Android 特定文档中特别提到您可以为自适应图标创建 XML 文件:
<platform name="android">
<!-- Default -->
<preference name="AndroidWindowSplashScreenAnimatedIcon" value="res/screen/android/splashscreen.xml" />
</platform>
Run Code Online (Sandbox Code Playgroud)
但我不知道这个splashscreen.xml文件中应该包含什么,而且我似乎找不到任何与之相关的具体文档 - 有什么想法应该放在这里吗?我们以前从未需要创建这个,因为其中的所有属性都config.xml足够了。
谢谢,本格拉
wub*_*bba 24
为了生成用于 cordova-android 11.0.0 应用程序中的闪屏的 XML 文件,我在 Android Studio 中创建了一个示例 Android 应用程序,并按照这些向示例应用程序添加图标的说明,将前景层指定为我想要的启动画面图标的 SVG 文件。我指定背景层为白色。然后我将新生成的文件复制MyApplication/app/src/main/res/drawable/ic_launcher_foreground.xml
到我的 Cordova 应用程序中并重命名它resources/android/splash/splashscreen.xml。
最后,我更新了 Cordova 应用程序的config.xml文件,如下所示:
<platform name="android">
<preference name="AndroidWindowSplashScreenAnimatedIcon" value="resources/android/splash/splashscreen.xml" />
<preference name="AndroidWindowSplashScreenBackground" value="#FFFFFF" />
</platform>
Run Code Online (Sandbox Code Playgroud)
可能值得注意的是,我的图标没有以任何方式动画。
经过大量的尝试和错误,我在这方面取得了一些进展。首先,我使用 Android Studio 创建了一个自适应图标。Livecode.com有一个关于如何做到这一点的非常好的指南。生成资产后,这将创建一个res包含以下内容的新文件夹:
C:\\MyApplication\\app\\src\\main\\res>tree /f\nFolder PATH listing for volume Windows\nVolume serial number is E47A-1E3F\nC:.\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80drawable\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80drawable-v24\n\xe2\x94\x82 ic_launcher_foreground.xml\n\xe2\x94\x82\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80layout\n\xe2\x94\x82 activity_main.xml\n\xe2\x94\x82\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80mipmap-anydpi-v26\n\xe2\x94\x82 ic_launcher.xml\n\xe2\x94\x82 ic_launcher_round.xml\n\xe2\x94\x82\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80mipmap-hdpi\n\xe2\x94\x82 ic_launcher.png\n\xe2\x94\x82 ic_launcher.webp\n\xe2\x94\x82 ic_launcher_foreground.png\n\xe2\x94\x82 ic_launcher_round.png\n\xe2\x94\x82 ic_launcher_round.webp\n\xe2\x94\x82\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80mipmap-mdpi\n\xe2\x94\x82 ic_launcher.png\n\xe2\x94\x82 ic_launcher.webp\n\xe2\x94\x82 ic_launcher_foreground.png\n\xe2\x94\x82 ic_launcher_round.png\n\xe2\x94\x82 ic_launcher_round.webp\n\xe2\x94\x82\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80mipmap-xhdpi\n\xe2\x94\x82 ic_launcher.png\n\xe2\x94\x82 ic_launcher.webp\n\xe2\x94\x82 ic_launcher_foreground.png\n\xe2\x94\x82 ic_launcher_round.png\n\xe2\x94\x82 ic_launcher_round.webp\n\xe2\x94\x82\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80mipmap-xxhdpi\n\xe2\x94\x82 ic_launcher.png\n\xe2\x94\x82 ic_launcher.webp\n\xe2\x94\x82 ic_launcher_foreground.png\n\xe2\x94\x82 ic_launcher_round.png\n\xe2\x94\x82 ic_launcher_round.webp\n\xe2\x94\x82\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80mipmap-xxxhdpi\n\xe2\x94\x82 ic_launcher.png\n\xe2\x94\x82 ic_launcher.webp\n\xe2\x94\x82 ic_launcher_foreground.png\n\xe2\x94\x82 ic_launcher_round.png\n\xe2\x94\x82 ic_launcher_round.webp\n\xe2\x94\x82\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80values\n\xe2\x94\x82 colors.xml\n\xe2\x94\x82 ic_launcher_background.xml\n\xe2\x94\x82 strings.xml\n\xe2\x94\x82 themes.xml\n\xe2\x94\x82\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80values-night\n themes.xml\nRun Code Online (Sandbox Code Playgroud)\n接下来,我更新了 Cordova 项目的config.xml文件,特别是AndroidWindowSplashScreenAnimatedIcon属性,以指向刚刚生成的Activity_main.xml文件:
C:\\MyApplication\\app\\src\\main\\res>tree /f\nFolder PATH listing for volume Windows\nVolume serial number is E47A-1E3F\nC:.\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80drawable\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80drawable-v24\n\xe2\x94\x82 ic_launcher_foreground.xml\n\xe2\x94\x82\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80layout\n\xe2\x94\x82 activity_main.xml\n\xe2\x94\x82\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80mipmap-anydpi-v26\n\xe2\x94\x82 ic_launcher.xml\n\xe2\x94\x82 ic_launcher_round.xml\n\xe2\x94\x82\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80mipmap-hdpi\n\xe2\x94\x82 ic_launcher.png\n\xe2\x94\x82 ic_launcher.webp\n\xe2\x94\x82 ic_launcher_foreground.png\n\xe2\x94\x82 ic_launcher_round.png\n\xe2\x94\x82 ic_launcher_round.webp\n\xe2\x94\x82\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80mipmap-mdpi\n\xe2\x94\x82 ic_launcher.png\n\xe2\x94\x82 ic_launcher.webp\n\xe2\x94\x82 ic_launcher_foreground.png\n\xe2\x94\x82 ic_launcher_round.png\n\xe2\x94\x82 ic_launcher_round.webp\n\xe2\x94\x82\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80mipmap-xhdpi\n\xe2\x94\x82 ic_launcher.png\n\xe2\x94\x82 ic_launcher.webp\n\xe2\x94\x82 ic_launcher_foreground.png\n\xe2\x94\x82 ic_launcher_round.png\n\xe2\x94\x82 ic_launcher_round.webp\n\xe2\x94\x82\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80mipmap-xxhdpi\n\xe2\x94\x82 ic_launcher.png\n\xe2\x94\x82 ic_launcher.webp\n\xe2\x94\x82 ic_launcher_foreground.png\n\xe2\x94\x82 ic_launcher_round.png\n\xe2\x94\x82 ic_launcher_round.webp\n\xe2\x94\x82\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80mipmap-xxxhdpi\n\xe2\x94\x82 ic_launcher.png\n\xe2\x94\x82 ic_launcher.webp\n\xe2\x94\x82 ic_launcher_foreground.png\n\xe2\x94\x82 ic_launcher_round.png\n\xe2\x94\x82 ic_launcher_round.webp\n\xe2\x94\x82\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80values\n\xe2\x94\x82 colors.xml\n\xe2\x94\x82 ic_launcher_background.xml\n\xe2\x94\x82 strings.xml\n\xe2\x94\x82 themes.xml\n\xe2\x94\x82\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80values-night\n themes.xml\nRun Code Online (Sandbox Code Playgroud)\n最后,如果您查看Activity_main.xml文件,它将包含一些引用约束布局的标记。如果您此时构建应用程序,您可能会收到如下错误:
\n\n\n错误:找不到属性layout_constraintBottom_toBottomOf(又名com.yjr.jinguantong:layout_constraintBottom_toBottomOf)。
\n
您的项目似乎缺少依赖项,您可以通过打开project.properties并添加以下属性来添加该依赖项:
cordova.system.library.2=com.android.support.constraint:constraint-layout:1.1.3\nRun Code Online (Sandbox Code Playgroud)\n在这个Github 问题页面上可以找到更多信息- 当然,将其添加到project.properties意味着如果您删除了平台文件夹,则必须手动重新添加它。我无法找到一种方法来简单地添加此依赖项。我确实通过从Activity_main.xml文件中删除一些约束标记来解决这个问题。我的项目是这样构建的:
\n<platform name="android">\n <preference name="AndroidWindowSplashScreenAnimatedIcon" value="res/screen/android/layout/activity_main.xml" />\n</platform>\nRun Code Online (Sandbox Code Playgroud)\n希望这对其他正在挣扎的人有帮助。
\n本格拉
\n我不确定这是否是最好的解决方案,但如果像我一样您只是想要快速简单的东西,您可以指向现有的图标文件之一(而不是新的 .xml),如下所示:
<platform name="android">
<!-- Default -->
<preference name="AndroidWindowSplashScreenAnimatedIcon" value="res/android/screen/splash-port-xxxhdpi.png"/>
</platform>
Run Code Online (Sandbox Code Playgroud)
我的图标文件是矩形的,在启动画面中它是圆形的,而且很小。不过,这对我来说已经足够好了。
| 归档时间: |
|
| 查看次数: |
23495 次 |
| 最近记录: |