[英]Splash screen on Android is not working
我在Cordova(6.2)上有一个应用程序并将其安装到Android设备(Android v6.0)中。 要更改应用程序图标,我替换/platforms/android/res/drawable-hdpi
的图标,它可以正常工作。 但是当我补充说
<platform name="android">
<preference name="SplashScreen" value="screen"/>
<preference name="SplashScreenDelay" value="1000" />
</platform>
到config.xml并重新编译应用程序 - 没有显示启动画面。
如何解决这个问题? (所有默认屏幕都出现在文件夹中,并且名称为screen.png
)
首先使用以下命令安装启动画面的插件:
cordova插件添加cordova-plugin-splashscreen
然后在config.xml中复制以下内容:
对于Android:
<platform name="android">
<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>
对于IOS:
<platform name="ios">
<splash src="res/screen/ios/Default~iphone.png" width="320" height="480"/>
<splash src="res/screen/ios/Default@2x~iphone.png" width="640" height="960"/>
<splash src="res/screen/ios/Default-Portrait~ipad.png" width="768" height="1024"/>
<splash src="res/screen/ios/Default-Portrait@2x~ipad.png" width="1536" height="2048"/>
<splash src="res/screen/ios/Default-Landscape~ipad.png" width="1024" height="768"/>
<splash src="res/screen/ios/Default-Landscape@2x~ipad.png" width="2048" height="1536"/>
<splash src="res/screen/ios/Default-568h@2x~iphone.png" width="640" height="1136"/>
<splash src="res/screen/ios/Default-667h.png" width="750" height="1334"/>
<splash src="res/screen/ios/Default-736h.png" width="1242" height="2208"/>
<splash src="res/screen/ios/Default-Landscape-736h.png" width="2208" height="1242"/>
</platform>
现在制作了超大尺寸的闪屏。 你可以用很多方法做到:
1) http://ionicframework.com/docs/cli/icon-splashscreen.html
现在将所有生成的文件放在res/screen/{platform}
文件夹中,并使用config.xml对条目进行双重检查
现在再次转到config.xml并添加以下内容:
<preference name="AutoHideSplashScreen" value="true" />
<preference name="SplashScreenDelay" value="3000" />
以上标签在3 seconds
后隐藏启动画面。
如果你还遇到问题,请告诉我。
希望它会有所帮助。
public class SplashScreen extends Activity {
private static int SPLASH_TIME_OUT = 3000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splashscreen);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent i = new Intent(SplashScreen.this,GetStartedScreen.class);
startActivity(i);
finish();
}
}, SPLASH_TIME_OUT);
}
}
在我将我的CLI更新到6.5.0并且插件的旧版Verison不支持最新的One之后,不会出现启动画面。 所以我删除了旧版( Cordova-plugin-splash screen 3.2.2“Splash screen” )并添加了最新的One()
删除插件使用:
cordova plugin remove cordova-plugin-splashscreen
添加插件使用:
cordova plugin addcordova-plugin-splashscreen
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.