To implement splash screen in android Phonegap its very simple and easy because
HTML5 made it easy for every developers to integrate animation and supportive
screen resolution with the help of html5 and css3
Here in order to assign simple splash screen all you need is to
1. add a line of code in the java file
HTML5 made it easy for every developers to integrate animation and supportive
screen resolution with the help of html5 and css3
Here in order to assign simple splash screen all you need is to
1. add a line of code in the java file
import android.os.Bundle;
import org.apache.cordova.*;
public class Test extends DroidGap {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl("file:///android_asset/www/index.html", 10000);
}
}
Here the splashscreen will be in drawable folder so the function
setIntegerProperty() will set the splash screen
Bcas when ever the android application open it will call the main
Activity the main activity
extends Droidgap so the compiler understood that the application
is webbased and start working
with the client library.
And for android you need to add config.xml in res folder
and add the folowing code there
<gap:splash src="img/splash/ios/test.png"
width="320" height="480" /> <gap:splash src="img/splash/ios/
_at_2x.png"
test
width="640" height="960" /> <gap:splash src="img/splash/ios/
_iphone5.png"
test
width="640" height="1136" /> <gap:splash src="img/splash/ios/
-Landscape.png"
test
width="1024" height="768" /> <gap:splash src="img/splash/ios/
-Portrait.png"
test
width="768" height="1024" /> <gap:splash src="img/splash/ios/
-vc-Portrait.png"
test
width="1536" height="2008" /> <gap:splash src="img/splash/ios/
-
test
-Landscape.png"
test
width="2048" height="1496" />
if you want to add the script add the following
// Wait for Cordova to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// Cordova is ready
//
function onDeviceReady() {
navigator.splashscreen.show();
}
in the head session after the cordova load
For android you will need different required sizes than iOS in some
cases,
which you can easily see again by looking at the defaults
currently in place
under the …/platforms/android/res folder within each of the drawable*
folders as shown in the screenshot below (icon.png
files need to be replaced with yours).
The sizes of the splash screens
for Android and how to implement them are
also explained here in the PhoneGap docs. The splash screens need to be
placed in the …/platforms/res/drawable folder
No comments:
Post a Comment