cordova-plugin-splashscreen
cordova-plugin-splashscreen copied to clipboard
Splash Screen Spinner Position
Feature Request
Motivation Behind Feature
We can't change the position of the spinner in splash screen, so it will be always centered
Feature Description
Currently the plugin doesn't offer a setting to position the spinner in splash screen, something like <preference name="SplashScreenSpinnerPosition" value="top|center|bottom" />
would be helpful
Alternatives or Workarounds
I didn't find any workarounds yet
plugins/cordova-plugin-splashscreen/src/
for android:
centeredLayout.setGravity(Gravity.BOTTOM|Gravity.CENTER);
and
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
u can see more about gravity and relativelayout here:
https://developer.android.com/reference/android/view/Gravity.html https://developer.android.com/reference/android/widget/RelativeLayout.html
for ios: CDVSplashScreen.m:
_activityView.center = CGPointMake(parentView.bounds.size.width / 2, parentView.bounds.size.height / 2 + number);
only change this number for position at center.
sorry about english, its not my native.
something like
<preference name="SplashScreenSpinnerPosition" value="top|center|bottom" />
would be helpful
Where would this position the spinner? Would center
be the current default?
something like
<preference name="SplashScreenSpinnerPosition" value="top|center|bottom" />
would be helpfulWhere would this position the spinner? Would
center
be the current default?
yeah, i think center its the best
@pedrovitor074
Thank you thank you, Gravity.BOTTOM|Gravity.CENTER
been looking for that.
Thanks @pedrovitor074.
You could just add a hook and set the position then:
(Attention: That's just super quick and dirty..)
config.xml:
<platform name="ios">
<hook src="hooks/after_build/after_build_modify_ios_spinner_position_action.js" type="after_build" />
</platform>
after_build_modify_ios_spinner_position_action.js
#!/usr/bin/env node
module.exports = function (context) {
console.log("Preparing iOS spinner position correction");
const fs = context.requireCordovaModule('fs');
const pathToProject = 'platforms/ios/YOUR_PROJECT_NAME/Plugins/cordova-plugin-splashscreen/CDVSplashScreen.m';
const pathToCDVSplashScreenFile = `${context.opts.projectRoot}/${pathToProject}`;
fs.access(pathToCDVSplashScreenFile, fs.F_OK, (err) => {
if (err) {
console.error(err);
return;
}
const dataRead = fs.readFileSync(pathToCDVSplashScreenFile, 'utf8');
const newData = dataRead.replace('_activityView.center = CGPointMake(parentView.bounds.size.width / 2, parentView.bounds.size.height / 2);', '_activityView.center = CGPointMake(parentView.bounds.size.width / 2, parentView.bounds.size.height / 2 + 50);');
fs.writeFileSync(pathToCDVSplashScreenFile, newData, 'utf8');
console.log("Done preparing iOS spinner position");
});
};
Make sure you replace the YOUR_PROJECT_NAME
.
Would be much better if someone would create a pull request and having the positions just in the config.xml file. But right now this works for me
Thanks @pedrovitor074.
You could just add a hook and set the position then:
(Attention: That's just super quick and dirty..)
config.xml:
<platform name="ios"> <hook src="hooks/after_build/after_build_modify_ios_spinner_position_action.js" type="after_build" /> </platform>
after_build_modify_ios_spinner_position_action.js
#!/usr/bin/env node module.exports = function (context) { console.log("Preparing iOS spinner position correction"); const fs = context.requireCordovaModule('fs'); const pathToProject = 'platforms/ios/YOUR_PROJECT_NAME/Plugins/cordova-plugin-splashscreen/CDVSplashScreen.m'; const pathToCDVSplashScreenFile = `${context.opts.projectRoot}/${pathToProject}`; fs.access(pathToCDVSplashScreenFile, fs.F_OK, (err) => { if (err) { console.error(err); return; } const dataRead = fs.readFileSync(pathToCDVSplashScreenFile, 'utf8'); const newData = dataRead.replace('_activityView.center = CGPointMake(parentView.bounds.size.width / 2, parentView.bounds.size.height / 2);', '_activityView.center = CGPointMake(parentView.bounds.size.width / 2, parentView.bounds.size.height / 2 + 50);'); fs.writeFileSync(pathToCDVSplashScreenFile, newData, 'utf8'); console.log("Done preparing iOS spinner position"); }); };
Make sure you replace the
YOUR_PROJECT_NAME
. Would be much better if someone would create a pull request and having the positions just in the config.xml file. But right now this works for me
Do you have this for Android Platform? Thank you in advance
Closing since the plugin no longer has iOS nor android code and spinner is not supported on browser nor windows