【问题标题】:How to set the position of spinner with cordova如何用科尔多瓦设置微调器的位置
【发布时间】:2016-10-11 10:57:23
【问题描述】:

我的 config.xml 中有这个

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

微调器效果很好,但是我需要将位置从center 垂直更改为center + 10% 之类的东西

有什么办法吗?

【问题讨论】:

  • 您将不得不编辑启动画面插件的源代码
  • @Akis 我正在使用phonegap builder。你能解释一下怎么做吗?

标签: android cordova phonegap-plugins


【解决方案1】:

你必须fork原来的cordova-plugin-splashscreen on github

然后在您的 config.xml 中将其更改为使用您的 fork,删除原始插件(类似于 &lt;plugin name="cordova-plugin-splashscreen" source="npm" /&gt;)并添加您的 fork &lt;plugin spec="https://github.com/youruser/cordova-plugin-splashscreen.git" /&gt;

你必须改变这行来做你想做的事 https://github.com/apache/cordova-plugin-splashscreen/blob/master/src/android/SplashScreen.java#L355-L370

现在它使对话框居中,我不确定如何完成你想要的,你必须弄清楚 Android 布局是如何工作的

您可以尝试使用 setY,因为 progressBar 是 View 子类,如下所示:

DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
int height = displaymetrics.heightPixels;
float position = (float) (height*0.4);
progressBar.setY(position);

【讨论】:

  • 另一个选项是编辑微调器本身。我相信这是正确的解决方案,因为我看不到“偏移”或重新定位“子视图”的其他方式:可以这么说,为微调器添加一些填充?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-07-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-08-23
相关资源
最近更新 更多