Cordova闪屏改变了微调器的位置?
有谁知道如何修改Cordova闪屏微调器的位置? 我检查了文档,找不到任何信息。
对于Android,一个类似的修复程序
platforms/android/src/org/apache/cordova/splashscreen/SplashScreen.java
在spinnerStart()
更改Gravity
值和RelativeLayout
规则。
例如,将微调器放在底部:
更改
centeredLayout.setGravity(Gravity.CENTER);
至
centeredLayout.setGravity(Gravity.BOTTOM);
并改变
layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
至
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
列出RelativeLayout选项: https : //developer.android.com/reference/android/widget/RelativeLayout.html
重力选项列表: https : //developer.android.com/reference/android/view/Gravity.html
好吧我想通了,不得不手动编辑“/ plugins / cordova-plugin-splashscreen / src / ios”中找到的iOS插件文件“CDVSplashScreen.m”。
_activityView.center = CGPointMake(parentView.bounds.size.width / 2, parentView.bounds.size.height / 2 + 75);
这样做使得微调器从屏幕中心向下75像素。 所以“+75”走向屏幕的底部“-75”会反过来。
希望这能帮助其他人(但不难发现)。
此外,如果要更改微调器的颜色。 有3个选项可供选择(不知道如何更改颜色)。
灰色(默认 – 搜索此行):
UIActivityIndicatorViewStyle topActivityIndicatorStyle = UIActivityIndicatorViewStyleGray
白色
UIActivityIndicatorViewStyle topActivityIndicatorStyle = UIActivityIndicatorViewStyleWhite;
whiteLarge
UIActivityIndicatorViewStyle topActivityIndicatorStyle = UIActivityIndicatorViewStyleWhiteLarge
在文件中找到:
/* * 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 * */
我可以用不同的方式为Android解决这个问题,不幸的是Matt的解决方案对我不起作用。
所以我所做的是在“spinnerStart”方法中使用原生填充方法作为进度条。 如果有人对我的解决方案感兴趣,我会从屏幕顶部为ios和android提供75%的填充(也集成了sputn1k的解决方案)。 当您需要不同的填充时,您可以根据需要进行分叉并进一步改进
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);