现在它似乎切断了图像顶部的十分之一,并在最初的几秒钟内覆盖了屏幕,然后我的应用程序正常启动,如下所示:
在我完成应用程序之前,我一直忽略它,现在我差点完成发布并希望解决这个问题。
我想知道是否有办法完全取出启动画面。我尝试从res / xml中删除图片并添加
<preference name="SplashScreen" value="none"/>
但不起作用。
这是一个Android应用程序。
我将在完成并发布Android版之后立即为iOS制作,所以如果它们是针对不同平台的不同方法,请加入。
答案 0 :(得分:2)
//splashscreen.js
var exec = require('cordova/exec');
var splashscreen = {
show:function() {
exec(null, null, "SplashScreen", "show", []);
},
hide:function() {
exec(null, null, "SplashScreen", "hide", []);
}
};
module.exports = splashscreen;
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="cordova-plugin-splashscreen"
version="2.1.0">
<name>Splashscreen</name>
<description>Cordova Splashscreen Plugin</description>
<license>Apache 2.0</license>
<keywords>cordova,splashscreen</keywords>
<repo>https://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen.git</repo>
<issue>https://issues.apache.org/jira/browse/CB/component/12320653</issue>
<engines>
<engine name="cordova-android" version=">=3.6.0" /><!-- Requires CordovaPlugin.preferences -->
</engines>
<js-module src="www/splashscreen.js" name="SplashScreen">
<clobbers target="navigator.splashscreen" />
</js-module>
<!-- android -->
<platform name="android">
<config-file target="res/xml/config.xml" parent="/*">
<feature name="SplashScreen">
<param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen"/>
<param name="onload" value="true"/>
</feature>
</config-file>
<source-file src="src/android/SplashScreen.java" target-dir="src/org/apache/cordova/splashscreen" />
</platform>
<!-- amazon-fireos -->
<platform name="amazon-fireos">
<config-file target="res/xml/config.xml" parent="/*">
<feature name="SplashScreen">
<param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen"/>
</feature>
</config-file>
<source-file src="src/android/SplashScreen.java" target-dir="src/org/apache/cordova/splashscreen" />
</platform>
<!-- ubuntu -->
<platform name="ubuntu">
<header-file src="src/ubuntu/splashscreen.h" />
<source-file src="src/ubuntu/splashscreen.cpp" />
</platform>
<!-- ios -->
<platform name="ios">
<config-file target="config.xml" parent="/*">
<feature name="SplashScreen">
<param name="ios-package" value="CDVSplashScreen"/>
<param name="onload" value="true"/>
</feature>
</config-file>
<header-file src="src/ios/CDVSplashScreen.h" />
<source-file src="src/ios/CDVSplashScreen.m" />
<header-file src="src/ios/CDVViewController+SplashScreen.h" />
<source-file src="src/ios/CDVViewController+SplashScreen.m" />
<framework src="CoreGraphics.framework" />
</platform>
<!-- blackberry10 -->
<platform name="blackberry10">
<source-file src="src/blackberry10/index.js" target-dir="SplashScreen" />
<config-file target="www/config.xml" parent="/widget">
<feature name="SplashScreen" value="SplashScreen"/>
</config-file>
</platform>
<!-- wp8 -->
<platform name="wp8">
<config-file target="config.xml" parent="/*">
<feature name="SplashScreen">
<param name="wp-package" value="SplashScreen"/>
<param name="onload" value="true"/>
</feature>
</config-file>
<source-file src="src/wp/SplashScreen.cs" />
<source-file src="src/wp/ResolutionHelper.cs" />
</platform>
<!-- windows8 -->
<platform name="windows8">
<js-module src="www/windows/SplashScreenProxy.js" name="SplashScreenProxy">
<merges target="" />
</js-module>
</platform>
<!-- windows -->
<platform name="windows">
<js-module src="www/windows/SplashScreenProxy.js" name="SplashScreenProxy">
<merges target="" />
</js-module>
</platform>
<!-- tizen -->
<platform name="tizen">
<js-module src="src/tizen/SplashScreenProxy.js" name="SplashScreenProxy">
<runs />
</js-module>
</platform>
<!-- browser -->
<platform name="browser">
<js-module src="src/browser/SplashScreenProxy.js" name="SplashScreenProxy">
<runs />
</js-module>
</platform>
</plugin>
//ReadMe
# cordova-plugin-splashscreen
[![Build Status](https://travis-ci.org/apache/cordova-plugin-splashscreen.svg)](https://travis-ci.org/apache/cordova-plugin-splashscreen)
This plugin displays and hides a splash screen during application launch.
## Installation
// npm hosted (new) id
cordova plugin add cordova-plugin-splashscreen
// you may also install directly from this repo
cordova plugin add https://github.com/apache/cordova-plugin-splashscreen.git
## Supported Platforms
- Amazon Fire OS
- Android
- BlackBerry 10
- iOS
- Windows Phone 7 and 8
- Windows 8
- Windows
- Browser
## Methods
- splashscreen.show
- splashscreen.hide
### Android Quirks
In your `config.xml`, you need to add the following preferences:
<preference name="SplashScreen" value="foo" />
<preference name="SplashScreenDelay" value="10000" />
<preference name="SplashMaintainAspectRatio" value="true|false" />
Where foo is the name of the splashscreen file, preferably a 9 patch file. Make sure to add your splashcreen files to your res/xml directory under the appropriate folders. The second parameter represents how long the splashscreen will appear in milliseconds. It defaults to 3000 ms. See [Icons and Splash Screens](http://cordova.apache.org/docs/en/edge/config_ref_images.md.html)
for more information.
"SplashMaintainAspectRatio" preference is optional. If set to true, splash screen drawable is not stretched to fit screen, but instead simply "covers" the screen, like CSS "background-size:cover". This is very useful when splash screen images cannot be distorted in any way, for example when they contain scenery or text. This setting works best with images that have large margins (safe areas) that can be safely cropped on screens with different aspect ratios.
The plugin reloads splash drawable whenever orientation changes, so you can specify different drawables for portrait and landscape orientations.
### Browser Quirks
You can use the following preferences in your `config.xml`:
<platform name="browser">
<preference name="SplashScreen" value="images/browser/splashscreen.jpg" /> <!-- defaults to "img/logo.png" -->
<preference name="SplashScreenDelay" value="10000" /> <!-- defaults to "3000" -->
<preference name="SplashScreenBackgroundColor" value="green" /> <!-- defaults to "#464646" -->
<preference name="ShowSplashScreen" value="false" /> <!-- defaults to "true" -->
<preference name="SplashScreenWidth" value="600" /> <!-- defaults to "170" -->
<preference name="SplashScreenHeight" value="300" /> <!-- defaults to "200" -->
</platform>
### iOS Quirks
- `FadeSplashScreen` (boolean, defaults to `true`): Set to `false` to
prevent the splash screen from fading in and out when its display
state changes.
<preference name="FadeSplashScreen" value="false"/>
- `FadeSplashScreenDuration` (float, defaults to `2`): Specifies the
number of seconds for the splash screen fade effect to execute.
<preference name="FadeSplashScreenDuration" value="4"/>
- `ShowSplashScreenSpinner` (boolean, defaults to `true`): Set to `false`
to hide the splash-screen spinner.
<preference name="ShowSplashScreenSpinner" value="false"/>
## splashscreen.hide
Dismiss the splash screen.
navigator.splashscreen.hide();
### BlackBerry 10, WP8, iOS Quirk
The `config.xml` file's `AutoHideSplashScreen` setting must be
`false`. To delay hiding the splash screen for two seconds, add a
timer such as the following in the `deviceready` event handler:
setTimeout(function() {
navigator.splashscreen.hide();
}, 2000);
## splashscreen.show
Displays the splash screen.
navigator.splashscreen.show();
Your application cannot call `navigator.splashscreen.show()` until the app has
started and the `deviceready` event has fired. But since typically the splash
screen is meant to be visible before your app has started, that would seem to
defeat the purpose of the splash screen. Providing some configuration in
`config.xml` will automatically `show` the splash screen immediately after your
app launch and before it has fully started and received the `deviceready`
event. See [Icons and Splash Screens](http://cordova.apache.org/docs/en/edge/config_ref_images.md.html)
for more information on doing this configuration. For this reason, it is
unlikely you need to call `navigator.splashscreen.show()` to make the splash
screen visible for app startup.
// to hide
cordova.exec(null, null, "SplashScreen", "hide", [])
// to show
cordova.exec(null, null, "SplashScreen", "show", [])
Or either replace default splash screen with your application specific screen or simply loader screen.
答案 1 :(得分:2)
您可以使用适用于不同平台(Android,iOS,Windows Phone,Amazon Fire等)的SplashScreen插件(cordova-plugin-splashscreen),然后您的代码中要做的第一件事就是隐藏启动画面像这样:
navigator.splashscreen.hide();
答案 2 :(得分:0)
事实证明我需要编辑(或删除)css文件夹中的index.css文件。现在它就像一个魅力:)
答案 3 :(得分:0)
尝试使用cordova插件删除启动屏幕&#39;
我正在开发一个phonegap应用程序(用于浏览器和android),它对我有用。