如何使用cordova设置微调器的位置
How to set the position of spinner with cordova
我的 config.xml
里有这个
<preference name="show-splash-screen-spinner" value="true" />
微调器效果很好,但是我需要将位置从 center
更改为 center + 10%
垂直
有什么办法吗?
你必须 fork 原来的 cordova-plugin-splashscreen on github
然后在您的 config.xml 上将其更改为使用您的分叉,删除原始插件(类似于 <plugin name="cordova-plugin-splashscreen" source="npm" />
)并添加您的分叉 <plugin spec="https://github.com/youruser/cordova-plugin-splashscreen.git" />
您必须更改此行才能执行您想要的操作
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);
我的 config.xml
里有这个<preference name="show-splash-screen-spinner" value="true" />
微调器效果很好,但是我需要将位置从 center
更改为 center + 10%
垂直
有什么办法吗?
你必须 fork 原来的 cordova-plugin-splashscreen on github
然后在您的 config.xml 上将其更改为使用您的分叉,删除原始插件(类似于 <plugin name="cordova-plugin-splashscreen" source="npm" />
)并添加您的分叉 <plugin spec="https://github.com/youruser/cordova-plugin-splashscreen.git" />
您必须更改此行才能执行您想要的操作 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);