[英]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.