I am using ProgressDialog
for showing progressbar
ProgressDialog progressDialog = new ProgressDialog(context);
progress
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/
In your Application Theme, change colorAccent
<style name="AppTheme.Bash" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">Add your color here</item>
<item name="android:windowBackground">@color/gray</item>
</style>
use whatever color you want
Get the resource from the android resource that being used by the ProgressDialog.
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);
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>