dev*_*dev 34 android android-progressbar
我ProgressDialog用来显示进度条
ProgressDialog progressDialog = new ProgressDialog(context);
progressDialog.setCancelable(false);
progressDialog.setMessage(message);
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressDialog.show();
Run Code Online (Sandbox Code Playgroud)
它就是这样的
我想将圆圈的绿色更改为红色.有什么办法吗?
我试过了
.getIndeterminateDrawable().setColorFilter(0xFFFFFFFF, android.graphics.PorterDuff.Mode.MULTIPLY);
Run Code Online (Sandbox Code Playgroud)
但不行.
Kap*_*put 43
在style.xml中为对话框创建样式:
<style name="AppCompatAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorAccent">@color/black</item>
<item name="android:textColorPrimary">@color/white</item>
<item name="android:background">@color/grey_dialog_box</item>
</style>
Run Code Online (Sandbox Code Playgroud)
在此 "android:textColorPrimary"需要定义要显示的颜色,并在java代码中定义样式ProgressDialog:
ProgressDialog progressDialog = new ProgressDialog(context,R.style.AppCompatAlertDialogStyle);
Run Code Online (Sandbox Code Playgroud)
更多:http://androidprogressdialogcustomcolor.blogspot.in/
小智 14
添加Style.xml
<style name="MyAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorAccent">@color/colorPrimary</item>
</style>
Run Code Online (Sandbox Code Playgroud)
将样式设置为进度对话框
pdialog = new ProgressDialog(context, R.style.MyAlertDialogStyle);
Run Code Online (Sandbox Code Playgroud)
Ume*_*ane 11
创建进度对话框的布局,在布局文件夹中命名为custom_progress_dialog.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="56dip" android:height="56dip" />
<gradient android:type="sweep" android:useLevel="false"
android:startColor="@android:color/transparent"
android:endColor="#1e9dff"
android:angle="0"
/>
</shape>
</rotate>
Run Code Online (Sandbox Code Playgroud)
确保indeterminate = true并android:indeterminateDrawable="@drawable/custom_progress_background"
在活动布局要使用装载机
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/loadingPanel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<ProgressBar
android:layout_width="wrap_content"
style="?android:attr/progressBarStyleLarge"
android:layout_height="wrap_content"
android:indeterminateDrawable="@drawable/custom_progress_dialog"
android:indeterminate="true" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
这不是一个完美的解决方案,但可能有所帮助.
另请查看我以前的评论. /sf/answers/2778152541/
final ProgressDialog progress = new ProgressDialog(this);
progress.setMessage(getString(R.string.progress_message));
progress.setIndeterminate(true);
progress.setCancelable(false);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
Drawable drawable = new ProgressBar(this).getIndeterminateDrawable().mutate();
drawable.setColorFilter(ContextCompat.getColor(this, R.color.colorAccent),
PorterDuff.Mode.SRC_IN);
progress.setIndeterminateDrawable(drawable);
}
progress.show();
Run Code Online (Sandbox Code Playgroud)
小智 5
从 ProgressDialog 使用的 android 资源中获取资源。
final ProgressDialog progress = new ProgressDialog(context);
progress.setTitle("Loading");
progress.setMessage("Wait while loading...");
progress.setCancelable(false); // disable dismiss by tapping outside of the dialog
progress.show();
ProgressBar progressbar=(ProgressBar)progress.findViewById(android.R.id.progress);
progressbar.getIndeterminateDrawable().setColorFilter(Color.parseColor("#C60000"), android.graphics.PorterDuff.Mode.SRC_IN);
Run Code Online (Sandbox Code Playgroud)
小智 4
尝试这个:
将颜色设置为红色的示例:
ProgressBar spinner = new android.widget.ProgressBar(
context,
null,
android.R.attr.progressBarStyle);
spinner.getIndeterminateDrawable().setColorFilter(0xFFFF0000, android.graphics.PorterDuff.Mode.MULTIPLY);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
45473 次 |
| 最近记录: |