首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >科多瓦11 -飞溅屏幕-在splashscreen.xml中是什么?

科多瓦11 -飞溅屏幕-在splashscreen.xml中是什么?
EN

Stack Overflow用户
提问于 2022-08-17 08:27:35
回答 3查看 3.9K关注 0票数 11

我目前正在尝试迁移到Cordova 11,并开始处理新的Splash屏幕API,但我发现文档并不是全部都很清楚。如果有人能在这方面给我指明方向,我会很感激的。

  1. 生成自适应图标的最佳方法是什么?
  2. 在Splash屏幕文档中,它在Android专用文档中特别提到可以为自适应图标创建一个XML文件:
代码语言:javascript
复制
<platform name="android">
    <!-- Default -->
    <preference name="AndroidWindowSplashScreenAnimatedIcon" value="res/screen/android/splashscreen.xml" />
</platform>

但是我不知道在这个splashscreen.xml文件中应该是什么,而且我似乎找不到任何与它具体相关的文档--有什么想法吗?由于config.xml中的所有属性都是足够的,我们以前从未创建过这样的属性。

谢谢你,本格拉赫

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2022-08-22 07:21:13

经过多次尝试和错误,我设法在这方面取得了一些进展。首先,我使用Android创建了一个Adaptive。Livecode.com对如何做到这一点有一个很好的指导。一旦生成这些资产,就会创建一个新的res文件夹,其内容如下:

代码语言:javascript
复制
C:\MyApplication\app\src\main\res>tree /f
Folder PATH listing for volume Windows
Volume serial number is E47A-1E3F
C:.
├───drawable
├───drawable-v24
│       ic_launcher_foreground.xml
│
├───layout
│       activity_main.xml
│
├───mipmap-anydpi-v26
│       ic_launcher.xml
│       ic_launcher_round.xml
│
├───mipmap-hdpi
│       ic_launcher.png
│       ic_launcher.webp
│       ic_launcher_foreground.png
│       ic_launcher_round.png
│       ic_launcher_round.webp
│
├───mipmap-mdpi
│       ic_launcher.png
│       ic_launcher.webp
│       ic_launcher_foreground.png
│       ic_launcher_round.png
│       ic_launcher_round.webp
│
├───mipmap-xhdpi
│       ic_launcher.png
│       ic_launcher.webp
│       ic_launcher_foreground.png
│       ic_launcher_round.png
│       ic_launcher_round.webp
│
├───mipmap-xxhdpi
│       ic_launcher.png
│       ic_launcher.webp
│       ic_launcher_foreground.png
│       ic_launcher_round.png
│       ic_launcher_round.webp
│
├───mipmap-xxxhdpi
│       ic_launcher.png
│       ic_launcher.webp
│       ic_launcher_foreground.png
│       ic_launcher_round.png
│       ic_launcher_round.webp
│
├───values
│       colors.xml
│       ic_launcher_background.xml
│       strings.xml
│       themes.xml
│
└───values-night
        themes.xml

接下来,我更新了我的Cordova项目的config.xml文件,特别是config.xml属性,指向刚刚生成的activity_main.xml文件:

代码语言:javascript
复制
<platform name="android">
   <preference name="AndroidWindowSplashScreenAnimatedIcon" value="res/screen/android/layout/activity_main.xml" />
</platform>

最后,如果您签出activity_main.xml文件,其中将包含一些与约束布局有关的标记。如果此时构建应用程序,可能会出现如下错误:

错误:属性layout_constraintBottom_toBottomOf (又名layout_constraintBottom_toBottomOf,未找到)。

看起来您的项目缺少一个依赖项,您可以通过打开project.properties并添加以下属性来添加该依赖项:

代码语言:javascript
复制
cordova.system.library.2=com.android.support.constraint:constraint-layout:1.1.3

在这个Github问题页面上有一些更多的信息-当然,将它添加到project.properties意味着如果您删除您的平台文件夹,您将不得不手动重新添加它。我无法找到一种简单地添加这个依赖项的方法。我确实是通过从activity_main.xml文件中删除一些约束标记来绕过它的。我的项目就是这样构建的:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity">

    <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" />

</androidx.constraintlayout.widget.ConstraintLayout>

希望这对其他挣扎的人有帮助。

本格拉赫

票数 2
EN

Stack Overflow用户

发布于 2022-09-08 16:54:49

为了在我的cordova-android 11.0.0中生成用于启动屏幕的XML文件,我在Android中创建了一个示例Android应用程序,然后按照这些指示将一个图标添加到示例应用程序中,我指定前台层为我想要的屏幕图标的SVG文件。我指定背景层为白色。然后,我将新生成的文件MyApplication/app/src/main/res/drawable/ic_launcher_foreground.xml复制到我的Cordova应用程序中,并将其重命名为resources/android/splash/splashscreen.xml

最后,我更新了我的Cordova应用程序的config.xml文件如下:

代码语言:javascript
复制
<platform name="android">
    <preference name="AndroidWindowSplashScreenAnimatedIcon" value="resources/android/splash/splashscreen.xml" />
    <preference name="AndroidWindowSplashScreenBackground" value="#FFFFFF" />
</platform>

这可能是值得注意的,我的图标不是动画在任何方面。

票数 7
EN

Stack Overflow用户

发布于 2022-11-30 17:34:15

我不确定这是否是最好的解决方案,但如果像我一样,您只想要一些快速而简单的东西,您可以指向一个现有的图标文件(而不是新的.xml),如下所示:

代码语言:javascript
复制
<platform name="android">
    <!-- Default -->
    <preference name="AndroidWindowSplashScreenAnimatedIcon" value="res/android/screen/splash-port-xxxhdpi.png"/>
</platform>

我的图标文件是矩形的,它是圆形的,而且很小。不过,这对我来说已经足够了。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73385204

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档