Thursday, October 20, 2016

How to set the position of spinner with cordova

Leave a Comment

I have this in my config.xml

<preference name="show-splash-screen-spinner" value="true" />  

And the spinner works great, however i need to change the position from center to something like center + 10% vertically

There is any way of doing this?

1 Answers

Answers 1

You have to fork the original cordova-plugin-splashscreen on github

Then on your config.xml you change it to use your fork, remove the original plugin (something like <plugin name="cordova-plugin-splashscreen" source="npm" />) and add your fork <plugin spec="https://github.com/youruser/cordova-plugin-splashscreen.git" />

You have to change this lines to do what you want https://github.com/apache/cordova-plugin-splashscreen/blob/master/src/android/SplashScreen.java#L355-L370

Right now it centers the dialog, I'm not really sure how to accomplish what you want, you'll have to figure out how Android layouts work

You can try to use setY as progressBar is a View subclass, something like this:

DisplayMetrics displaymetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); int height = displaymetrics.heightPixels; float position = (float) (height*0.4); progressBar.setY(position); 
If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment