简体   繁体   English

PhoneGap启动画面,说明不清晰

[英]PhoneGap Splash Screen, instruction not clear

I recently decide to work on PhoneGap to write apps on multiple devices. 我最近决定使用PhoneGap在多个设备上编写应用程序。 Every time I try to use a plugin, it works after a lot of hours and hundreds and hundreds search on Google... and some time it not working at all for me. 每次我尝试使用插件时,都会在经过数小时的时间和在Google上进行成百上千次搜索后才能正常工作,有时它对我来说根本不起作用。 So I probably do not understand the basic knowledge of PhoneGap. 因此,我可能不了解PhoneGap的基本知识。

Let's talk about a simple plugin, the Splash Screen plugin ( https://github.com/apache/cordova-plugin-splashscreen ). 让我们谈谈一个简单的插件,即Splash Screen插件( https://github.com/apache/cordova-plugin-splashscreen )。

On the plugin instruction, I understand that I need to write those lines in config.xml: 关于插件说明,我了解我需要在config.xml中编写这些行:

<preference name="SplashScreen" value="foo" />
<preference name="SplashScreenDelay" value="3000" />
<preference name="SplashMaintainAspectRatio" value="true|false" />
<preference name="SplashShowOnlyFirstTime" value="true|false" />

But if you read the instruction in a link found in the Android part ( http://cordova.apache.org/docs/en/dev/config_ref/images.html ) I should write these lines in config.xml: 但是,如果您在Android部分( http://cordova.apache.org/docs/en/dev/config_ref/images.html )中的链接中阅读了说明,则应在config.xml中写这些行:

<platform name="android">
    <!-- you can use any density that exists in the Android project -->
    <splash src="res/screen/android/splash-land-hdpi.png" density="land-hdpi"/>
    <splash src="res/screen/android/splash-land-ldpi.png" density="land-ldpi"/>
    <splash src="res/screen/android/splash-land-mdpi.png" density="land-mdpi"/>
    <splash src="res/screen/android/splash-land-xhdpi.png" density="land-xhdpi"/>

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

I tried both instruction and it's not working. 我尝试了两种指示,但没有用。 I found also other instruction on PhoneGap Build and I suppose to write these liens in the config.xml: 我还在PhoneGap Build上找到了其他说明,我想将这些留置权写在config.xml中:

<splash src="ldpi.png" platform="android" qualifier="ldpi" />
<splash src="mdpi.png" platform="android" qualifier="mdpi" />
<splash src="hdpi.png" platform="android" qualifier="hdpi" />
<splash src="xhdpi.png" platform="android" qualifier="xhdpi" />
<splash src="fr-xhdpi.png" platform="android" qualifier="fr-xhdpi" />
<splash src="portrait-xxhdpi.png" platform="android" qualifier="port-xxhdpi" />
<splash src="landscape-xxhdpi.png" platform="android" qualifier="land-xxhdpi" />

and to confuse me more, if I check the "default" config.xml that PhoneGap generates, I found these lines: 更让我困惑的是,如果我检查PhoneGap生成的“默认” config.xml,则会发现以下几行:

  <gap:splash src="www/res/screen/android/screen-ldpi-portrait.png" gap:platform="android" gap:qualifier="port-ldpi"/>
  <gap:splash src="www/res/screen/android/screen-mdpi-portrait.png" gap:platform="android" gap:qualifier="port-mdpi"/>
  <gap:splash src="www/res/screen/android/screen-hdpi-portrait.png" gap:platform="android" gap:qualifier="port-hdpi"/>
  <gap:splash src="www/res/screen/android/screen-xhdpi-portrait.png" gap:platform="android" gap:qualifier="port-xhdpi"/>

As you can see, sometime the source file starts with 'www' or 'res', sometime we have a that <splash> inside the <platform> element or platform is an attribute of <splash> element. 正如你所看到的,有时在源文件开头的“www”或“资源”,有时我们有一个是<splash>内部<platform>元素或平台的属性<splash>元素。
What is the difference between the <splash> and <gap:splash> element? <splash><gap:splash>元素有什么区别?

I'm very confused with instructions found in the PhoneGap API, PhoneGap Build API and Plugin web page. 我对PhoneGap API,PhoneGap Build API和插件网页中的说明感到非常困惑。

I'm using PhoneGap 5.3.9 on a Mac. 我在Mac上使用的是PhoneGap 5.3.9。 I test my app using the Android PhoneGap app or using PhoneGap Build (cli-5.2.0). 我使用Android PhoneGap应用程序或PhoneGap Build(cli-5.2.0)测试我的应用程序。

I recently started using Cordova (the open source version of phonegap) and I too struggled. 我最近开始使用Cordova(phonegap的开源版本),我也很挣扎。 However, there's a few things I learned that I think may help make things more clear for you. 但是,我了解到一些事情,我认为这可能有助于使您更清楚地了解情况。

Phonegap is meant to make your code on multiple platforms (iOS, android, etc). Phonegap旨在使您的代码在多个平台(iOS,Android等)上。 All the files you see in the 'platforms' directory are meant for specific platforms. 您在“平台”目录中看到的所有文件均适用于特定平台。 You should only edit these files if you want to make changes for a specific platform that won't affect the other platforms. 仅当您要对不会影响其他平台的特定平台进行更改时,才应编辑这些文件。 Each platform has its own config.xml file that it uses in addition to the config file found in your project root folder. 每个平台除了在项目根文件夹中找到的配置文件外,还使用自己的config.xml文件。 Assuming that you're not trying to make your splash screen specifically for Android but want it to look the same across every platform, you should only edit the config.xml found in your project root folder. 假设您不是要专门针对Android创建启动屏幕,而是希望它在每个平台上都看起来一样,则只应编辑在项目根文件夹中找到的config.xml。

I would try using only the 1st and 3rd blocks of code you posted. 我会尝试仅使用您发布的第一和第三代码段。 The 2nd one is for Android specific customization. 第二个是针对Android的定制。 And I'm not sure about the 4th one. 我不确定第四个。

As for it not working, I recommend you use a debugger to pinpoint what is not working. 至于它不起作用,我建议您使用调试器来查明不起作用的地方。 For debugging android, I used Chrome Remote Debugging: https://developer.chrome.com/devtools/docs/remote-debugging 为了调试android,我使用了Chrome远程调试: https//developer.chrome.com/devtools/docs/remote-debugging

From there, you can look at the console logs and it will probably tell you something about your plugin not being loaded. 从那里,您可以查看控制台日志,它可能会告诉您有关未加载插件的信息。 And if not, it has a few tools you can use to pinpoint why your plugin isn't working (breakpoints, log statements). 如果没有,它可以使用一些工具来确定插件不起作用的原因(断点,日志语句)。

Hope this helps! 希望这可以帮助! If not, you can ask me and might be able to offer further advice. 如果没有,您可以问我,也许可以提供进一步的建议。

One very important point when using cordova is, to decide to use cordova or a variant of it, like phonegap, ionic, … 使用Cordova时非常重要的一点是,决定使用Cordova或它的变体,例如phonegap,ionic,…

If you made this decision, then follow only the appropriate documentation, don't mix it with other documentation and use just the newest docs. 如果您做出了此决定,请仅遵循适当的文档,不要将其与其他文档混合使用,而只能使用最新的文档。 Cordova is very heavily developed and there are a lot of changes. 科尔多瓦非常发达,并且有很多变化。 That means, that every varaint of cordova is based on an older version of cordova. 这就是说,科尔多瓦的每一种变异都基于科尔多瓦的旧版本。

Another important point is, that the variants use an other syntax, phonegap settings for example are starting with 另一个重要的一点是,这些变体使用了其他语法,例如phonegap设置以

You should make the settings of your project in the config.xml in the root of your project. 您应该在项目根目录的config.xml中进行项目设置。 On every build of your project, cordova will use this settings. 在项目的每个内部版本中,cordova都将使用此设置。

In this config.xml you can have global settings and platform settings. 在此config.xml中,您可以具有全局设置和平台设置。 Platform settings are looking like this: 平台设置如下所示:

<platform name="android">
   // Here your settings for android
</platform>

Working settings for the icons and splashscreens you can find here: 您可以在以下位置找到图标和启动屏幕的工作设置:

http://cordova.apache.org/docs/en/dev/config_ref/images.html http://cordova.apache.org/docs/en/dev/config_ref/images.html

If you want to have very sharp icons and splashscreens, then you should create the different sizes by yourself and use a vector software for that. 如果您想拥有非常清晰的图标和启动画面,则应自己创建不同的大小并为此使用矢量软件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM