更改对话框中的圆圈图标
Change circle icon in Dialog
我有一个使用此代码的对话框:
progressDialog = new ProgressDialog(this);
//-------------------------------------
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
progressDialog.setIndeterminateDrawable(getResources().getDrawable(R.drawable.custom_progress_background, getTheme()));
}
else{
progressDialog.setIndeterminateDrawable(getResources().getDrawable(R.drawable.custom_progress_background));
}
//-------------------------------------
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressDialog.setMessage(getString(R.string.MSG_SEARCH_DOING));
progressDialog.setCancelable(false);
progressDialog.setCanceledOnTouchOutside(false);
progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel_msg), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
isStop = true;
isCancel = true;
showWaitingDialog();
}
});
progressDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
}
});
progressDialog.show();
并有输出:
但我想要这样的微调器:
任何人都可以帮助我在不使用第三个库的情况下做到这一点?
在res目录下新建一个xml
文件夹,将progressbar.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="72dip" android:height="72dip" />
<gradient android:type="sweep" android:useLevel="false"
android:startColor="#448a29"
android:endColor="#447829"
android:angle="0"
/>
</shape>
</rotate>
根据您的选择设置开始颜色和结束颜色。
现在在 ProgressBar 的背景中设置 progress.xml
。
像这样
<ProgressBar
android:id="@+id/ProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background ="@xml/progressbar">
您使用了这个示例和库 https://github.com/afollestad/material-dialogs
您可以像这样自定义您的进度对话框,这正是您要找的
ACProgressFlower dialog = new ACProgressFlower.Builder(this)
.direction(ACProgressConstant.DIRECT_CLOCKWISE)
.themeColor(Color.WHITE)
.text("Title is here)
.fadeColor(Color.DKGRAY).build();
dialog.show();
有关更多信息,请参阅 this
使用这行代码更改进度图标
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
progressDialog.setIndeterminateDrawable(getResources.getDrawable(R.drawable.custom_progress_drawable,getTheme()));
}else{
progressDialog.setIndeterminateDrawable(getResources.getDrawable(R.drawable.custom_progress_drawable));
}
你至少需要 4 张图片来制作这个 custom_progress_drawable.xml,它可以按以下方式创建:
<animation-list>
<item android:drawable="@drawable/image1" android:duration="100" />
<item android:drawable="@drawable/image2" android:duration="100" />
<item android:drawable="@drawable/image3" android:duration="100" />
<item android:drawable="@drawable/image4" android:duration="100" /></animation-list>
现在将此可绘制对象设置为进度对话框中的中间可绘制对象
我有一个使用此代码的对话框:
progressDialog = new ProgressDialog(this);
//-------------------------------------
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
progressDialog.setIndeterminateDrawable(getResources().getDrawable(R.drawable.custom_progress_background, getTheme()));
}
else{
progressDialog.setIndeterminateDrawable(getResources().getDrawable(R.drawable.custom_progress_background));
}
//-------------------------------------
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressDialog.setMessage(getString(R.string.MSG_SEARCH_DOING));
progressDialog.setCancelable(false);
progressDialog.setCanceledOnTouchOutside(false);
progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel_msg), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
isStop = true;
isCancel = true;
showWaitingDialog();
}
});
progressDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
}
});
progressDialog.show();
并有输出:
但我想要这样的微调器:
在res目录下新建一个xml
文件夹,将progressbar.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="72dip" android:height="72dip" />
<gradient android:type="sweep" android:useLevel="false"
android:startColor="#448a29"
android:endColor="#447829"
android:angle="0"
/>
</shape>
</rotate>
根据您的选择设置开始颜色和结束颜色。
现在在 ProgressBar 的背景中设置 progress.xml
。
像这样
<ProgressBar
android:id="@+id/ProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background ="@xml/progressbar">
您使用了这个示例和库 https://github.com/afollestad/material-dialogs
您可以像这样自定义您的进度对话框,这正是您要找的
ACProgressFlower dialog = new ACProgressFlower.Builder(this)
.direction(ACProgressConstant.DIRECT_CLOCKWISE)
.themeColor(Color.WHITE)
.text("Title is here)
.fadeColor(Color.DKGRAY).build();
dialog.show();
有关更多信息,请参阅 this
使用这行代码更改进度图标
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
progressDialog.setIndeterminateDrawable(getResources.getDrawable(R.drawable.custom_progress_drawable,getTheme()));
}else{
progressDialog.setIndeterminateDrawable(getResources.getDrawable(R.drawable.custom_progress_drawable));
}
你至少需要 4 张图片来制作这个 custom_progress_drawable.xml,它可以按以下方式创建:
<animation-list>
<item android:drawable="@drawable/image1" android:duration="100" />
<item android:drawable="@drawable/image2" android:duration="100" />
<item android:drawable="@drawable/image3" android:duration="100" />
<item android:drawable="@drawable/image4" android:duration="100" /></animation-list>
现在将此可绘制对象设置为进度对话框中的中间可绘制对象