混合应用开发 欢迎界面 (二)

孤街浪徒 提交于 2019-12-06 01:22:27

本文将介绍如何为混合应用加入欢迎界面,本教程将在教程一的代码上进行修改。

为混合应用加入欢迎界面可以使用Cordova SplashScreen插件。

一,增加不同尺寸的欢迎界面图片资源

二,在config.xml增加SplashScreen插件配置

1,SplashScreen属性value值对应图片名称

<preference name="splashscreen" value="splash" />

2,SplashScreenDelay属性value值表示欢迎界面关闭时间

<preference name="SplashScreenDelay" value="5000" />
3,完整配置:


<?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.
-->
<widget xmlns     = "http://www.w3.org/ns/widgets"
        id        = "io.cordova.helloCordova"
        version   = "2.0.0">
    <name>Hello Cordova</name>

    <description>
        A sample Apache Cordova application that responds to the deviceready event.
    </description>

    <author href="http://cordova.io" email="dev@cordova.apache.org">
        Apache Cordova Team
    </author>

    <access origin="*"/>

    <!-- <content src="http://mysite.com/myapp.html" /> for external pages -->
    <content src="index.html" />

    <preference name="loglevel" value="DEBUG" />
    <preference name="splashscreen" value="splash" />
    <preference name="SplashScreenDelay" value="5000" />
    <preference name="backgroundColor" value="0xFFF" />
    <!--<preference name="loadUrlTimeoutValue" value="5000" />
    <preference name="InAppBrowserStorageEnabled" value="true" />
    <preference name="disallowOverscroll" value="true" />-->
    <!-- This is required for native Android hooks -->
    <feature name="App">
        <param name="android-package" value="org.apache.cordova.App" />
    </feature>
    
    <feature name="SplashScreen">
        <param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen" />
    </feature>
</widget>

三,运行效果


四,源码及安装包地址https://git.oschina.net/czpae86/Hybrid-Apps.git




易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!