Cordova 启动画面改变微调器的位置?

Cordova splash screen change the position of the spinner?

有谁知道如何修改 Cordova 初始屏幕微调器的位置?我已经检查了文档,但找不到任何信息。

好的,我明白了,必须手动编辑“/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; 

白色大号

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,

中有类似的修复

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

我可以用不同的方式为 Android 解决这个问题,不幸的是 Matt 的解决方案对我不起作用。

所以我所做的是在 "spinnerStart" 方法中对进度条使用本机填充方法。 如果有人对我的解决方案感兴趣,我在 ios&android 的屏幕顶部有 75% 的填充(也集成了 sputn1k 的解决方案)。 当您需要不同的 padding

时,您可以 Fork 并根据您的需要进一步改进它

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);