【问题标题】:Cordova splash screen change the position of the spinner?Cordova 闪屏改变微调器的位置?
【发布时间】:2016-08-12 14:41:48
【问题描述】:

有人知道如何修改 Cordova 闪屏微调器的位置吗?我检查了文档,找不到任何信息。

【问题讨论】:

    标签: javascript ios cordova spinner splash-screen


    【解决方案1】:

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

    所以我所做的是在“spinnerStart”方法中为进度条使用原生填充方法。 如果有人对我的解决方案感兴趣,我从屏幕顶部为 ios 和 android 有 75% 的填充(sputn1k 的解决方案也被集成)。 当您需要不同的填充时,您可以 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);
    

    【讨论】:

      【解决方案2】:

      对于 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

      【讨论】:

      • 感谢@matt 目前只需要 iOS 版本,但稍后会派上用场!欢呼
      • Android:如果我只是想将它向上移动一点怎么办?我们可以给它数值吗,我们在 HTML 中使用的方式,例如40像素等
      • 底部中心是什么?
      【解决方案3】:

      好的,我想通了,必须手动编辑在“/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
       *
       */
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-12-20
        • 1970-01-01
        • 1970-01-01
        • 2018-12-01
        • 1970-01-01
        相关资源
        最近更新 更多