I am using ProgressDialog
for showing progressbar
ProgressDialog progressDialog = new ProgressDialog(context);
progressDialog.setCancelable(false);
progressDialog.setMessage(message);
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progressDialog.show();
And it is coming like this
I want to change the green color of the circle to red. is there any way?
I tried
.getIndeterminateDrawable().setColorFilter(0xFFFFFFFF, android.graphics.PorterDuff.Mode.MULTIPLY);
But not working.
In style.xml create style for dialog box :
<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>
In this "android:textColorPrimary"
need to define color you want to show and in java code define style of ProgressDialog
like :
ProgressDialog progressDialog = new ProgressDialog(context,R.style.AppCompatAlertDialogStyle);
MORE : http://androidprogressdialogcustomcolor.blogspot.in/
Add Style.xml
<style name="MyAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorAccent">@color/colorPrimary</item>
</style>
set style to progress dialog
pdialog = new ProgressDialog(context, R.style.MyAlertDialogStyle);
Create layout for progress dialog as named as custom_progress_dialog.xml in drawable folder.
<?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>
make sure that indeterminate = true
and android:indeterminateDrawable="@drawable/custom_progress_background"
In the activity layout where you want to use the loader
<?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>
This is not a perfect solution, but may help.
Also check my previous comment. https://stackoverflow.com/a/39687893/2598453
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();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With