有没有办法在启动画面中自定义微调器? 目前我正在使用cordova splashscreen插件,我想更改启动画面上显示的微调器的颜色。
答案 0 :(得分:3)
在platforms/android/src/org/apache/cordova/splashscreen/SplashScreen.java
,顶部:
import android.graphics.drawable.Drawable;
import android.content.res.Resources;
进一步深入底部替换为此功能:
// Show only spinner in the center of the screen
private void spinnerStart() {
cordova.getActivity().runOnUiThread(new Runnable() {
public void run() {
spinnerStop();
spinnerDialog = new ProgressDialog(webView.getContext());
spinnerDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
public void onCancel(DialogInterface dialog) {
spinnerDialog = null;
}
});
spinnerDialog.setCancelable(false);
spinnerDialog.setIndeterminate(true);
Resources activityRes = cordova.getActivity().getResources();
int spinnerResId = activityRes.getIdentifier("customspinner", "drawable", cordova.getActivity().getPackageName());
Drawable customSpinner = activityRes.getDrawable(spinnerResId);
RelativeLayout centeredLayout = new RelativeLayout(cordova.getActivity());
centeredLayout.setGravity(Gravity.CENTER);
centeredLayout.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
ProgressBar progressBar = new ProgressBar(webView.getContext());
progressBar.setIndeterminateDrawable(customSpinner);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
progressBar.setLayoutParams(layoutParams);
centeredLayout.addView(progressBar);
spinnerDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
spinnerDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
spinnerDialog.show();
spinnerDialog.setContentView(centeredLayout);
}
});
}
在platforms/android/res/drawable
中 - 添加文件夹(如果该文件夹不存在) - 添加文件customspinner.xml
:
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:pivotX="50%" android:pivotY="50%" android:fromDegrees="0"
android:toDegrees="360">
<shape android:shape="ring" android:innerRadiusRatio="3"
android:thicknessRatio="8" android:useLevel="false">
<size android:width="76dip" android:height="76dip" />
<gradient android:type="sweep" android:useLevel="false"
android:startColor="#FFFFFFFF"
android:endColor="#00FFFFFF"
android:angle="0"
/>
</shape>
</rotate>
答案 1 :(得分:-1)
为ion-spinner
提供颜色并不困难。你可以这样做
CSS
.spinner svg {
width: 28px;
height: 28px;
stroke: #444;
fill: #444;
}
HTML 的
<ion-spinner icon="circles "class="spinner-energized"></ion-spinner>
根据Ionic Docs。