Does anyone know how to modify the position of the Cordova splash screen spinner? I have checked the documentation and couldn\'t find any information.
Ok I figured it out, had to manually edit the iOS plugin file "CDVSplashScreen.m" found inside "/plugins/cordova-plugin-splashscreen/src/ios".
_activityView.center = CGPointMake(parentView.bounds.size.width / 2, parentView.bounds.size.height / 2 + 75);
What that does is makes the spinner 75 pixels lower from the centre of the screen. so "+75" goes towards the bottom of the screen "-75" would do the opposite.
Hope this helps someone else out there (but wasn't to hard to figure out).
Additionally if you want to change the colour of the spinner. There are 3 options to choose from (no idea how to change the colour).
gray (default - search for this line):
UIActivityIndicatorViewStyle topActivityIndicatorStyle = UIActivityIndicatorViewStyleGray
white
UIActivityIndicatorViewStyle topActivityIndicatorStyle = UIActivityIndicatorViewStyleWhite;
whiteLarge
UIActivityIndicatorViewStyle topActivityIndicatorStyle = UIActivityIndicatorViewStyleWhiteLarge
Found in the files:
/*
* The Activity View is the top spinning throbber in the status/battery bar. We init it with the default Grey Style.
*
* whiteLarge = UIActivityIndicatorViewStyleWhiteLarge
* white = UIActivityIndicatorViewStyleWhite
* gray = UIActivityIndicatorViewStyleGray
*
*/
For android, a similar fix is in
platforms/android/src/org/apache/cordova/splashscreen/SplashScreen.java
in spinnerStart()
change the Gravity
value, and RelativeLayout
rule.
e.g. to put spinner at the bottom:
change
centeredLayout.setGravity(Gravity.CENTER);
to
centeredLayout.setGravity(Gravity.BOTTOM);
and change
layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
to
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
List RelativeLayout options: https://developer.android.com/reference/android/widget/RelativeLayout.html
List of Gravity options: https://developer.android.com/reference/android/view/Gravity.html
I could fix this for Android in a different way, unfortunately the solution from Matt did not work for me.
So what i did was to use a native Padding Method for the progressbar inside the "spinnerStart" Method. If anyone is interested in my solution, i have 75% padding from top of the Screen for both ios&android (sputn1k´s solution is also integrated). You can Fork and further improve it for your needs when you need a different padding
https://github.com/kaya18/cordova-plugin-splashscreen/
final WindowManager win = (WindowManager)webView.getContext().getSystemService(Context.WINDOW_SERVICE);
final Display display = win.getDefaultDisplay();
final Point size = new Point();
display.getRealSize(size);
// add padding to (top) spinner
progressBar.setPadding(0, (size.y / 2), 0, 0);
centeredLayout.addView(progressBar);