使用Phonegap

时间:2017-02-07 08:57:51

标签: android cordova phonegap-build splash-screen

我正在使用Phonegap构建应用程序,但我无法在Android上使用启动画面。

但图标工作正常。

这是我的config.xml:

<?xml version='1.0' encoding='utf-8'?>
    <widget id="com.example.app"
            version="1.0.0"
            xmlns="http://www.w3.org/ns/widgets"
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:gap="http://phonegap.com/ns/1.0">

        <name>TestAppName</name>
        <description>
            Test description
        </description>
        <author email="123@asd.com" href="http://example.com">
            Author
        </author>

        <plugin name="cordova-plugin-geolocation" source="npm" spec="~2.4.0" />
        <plugin name="cordova-plugin-globalization" source="npm" spec="~1.0.5" />
        <plugin name="cordova-plugin-network-information" source="npm" spec="~1.3.1" />
        <plugin name="cordova-plugin-splashscreen" source="npm" spec="~4.0.1" />
        <plugin name="cordova-plugin-whitelist" source="npm" spec="~1.3.1" />

        <preference name="permissions" value="none"/>
        <preference name="orientation" value="portrait" />
        <preference name="target-device" value="universal" />
        <preference name="fullscreen" value="true" />
        <preference name="webviewbounce" value="true" />
        <preference name="prerendered-icon" value="true" />
        <preference name="stay-in-webview" value="false" />
        <preference name="ios-statusbarstyle" value="black-opaque" />
        <preference name="detect-data-types" value="false" />
        <preference name="exit-on-suspend" value="false" />
        <preference name="disable-cursor" value="false" />

        <preference name="android-installLocation" value="auto" />
        <preference name="android-minSdkVersion" value="14" />

        <preference name="DisallowOverscroll" value="false" />

        <preference name="ShowSplashScreen" value="true" />
        <preference name="ShowSplashScreenSpinner" value="false" />
        <preference name="SplashScreen" value="screen" />
        <preference name="SplashScreenDelay" value="3001"/>
        <preference name="SplashShowOnlyFirstTime" value="false" />
        <preference name="FadeSplashScreen" value="false"/>

        <content src="index.html" />

        <gap:config-file platform="android" parent="/manifest">
            <supports-screens
                    android:xlargeScreens="true"
                    android:largeScreens="true"
                    android:smallScreens="true" />
            <application android:theme="@android:style/Theme.NoTitleBar" >
                <activity android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
                </activity>
            </application>
        </gap:config-file>

        <platform name="android">
            <icon density="ldpi" src="www/res/icon/android/drawable-ldpi-icon.png" />
            <icon density="mdpi" src="www/res/icon/android/drawable-mdpi-icon.png" />
            <icon density="hdpi" src="www/res/icon/android/drawable-hdpi-icon.png" />
            <icon density="xhdpi" src="www/res/icon/android/drawable-xhdpi-icon.png" />
            <icon density="xxhdpi" src="www/res/icon/android/drawable-xxhdpi-icon.png" />
            <icon density="xxxhdpi" src="www/res/icon/android/drawable-xxxhdpi-icon.png" />

            <splash density="port-mdpi" src="www/res/screen/android/drawable-mdpi/background.9.png" />
            <splash density="port-hdpi" src="www/res/screen/android/drawable-hdpi/background.9.png" />
            <splash density="port-xhdpi" src="www/res/screen/android/drawable-xhdpi/background.9.png" />
            <splash density="port-xxhdpi" src="www/res/screen/android/drawable-xxhdpi/background.9.png" />
            <splash density="port-xxxhdpi" src="www/res/screen/android/drawable-xxxhdpi/background.9.png" />
        </platform>

        <access origin="*" />

        <allow-intent href="http://*/*" />
        <allow-intent href="https://*/*" />
        <allow-intent href="tel:*" />
        <allow-intent href="sms:*" />
        <allow-intent href="mailto:*" />
        <allow-intent href="geo:*" />

        <platform name="android">
            <allow-intent href="market:*" />
        </platform>
    </widget>

当拥有通用启动画面时,以及项目根目录中的图像可以正常工作

<splash src="splash.png" />

问题是在Android设备上安装应用时,分辨率不正确。

我使用:ticons.fokkezb.nl生成了屏幕 是的;)我仔细检查文件路径是否正确。

有谁知道如何让启动画面工作?非常感谢。

1 个答案:

答案 0 :(得分:0)

在配置中包含启动画面的路径

 <splash density="port-ldpi" src="www/res/screen/android/drawable-port-ldpi-screen.png" />
 <splash density="port-mdpi" src="www/res/screen/android/drawable-port-mdpi-screen.png" />
 <splash density="port-hdpi" src="www/res/screen/android/drawable-port-hdpi-screen.png" />
 <splash density="port-xhdpi" src="www/res/screen/android/drawable-port-xhdpi-screen.png" />
 <splash density="port-xxhdpi" src="www/res/screen/android/drawable-port-xxhdpi-screen.png" />
 <splash density="port-xxxhdpi" src="www/res/screen/android/drawable-port-xxxhdpi-screen.png" />

所以不要给&#34; background.9.png&#34;为您的图像命名。给&#34; drawable-port-ldpi-screen.png&#34; ,&#34; drawable-port-mdpi-screen.png&#34;等