How to change default ProgressDialog circle color in android

前端 未结 10 907
夕颜
夕颜 2020-12-24 11:01

I am using ProgressDialog for showing progressbar

            ProgressDialog progressDialog = new ProgressDialog(context);
            progress         


        
相关标签:
10条回答
  • 2020-12-24 11:52

    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/

    0 讨论(0)
  • 2020-12-24 11:52

    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

    0 讨论(0)
  • 2020-12-24 11:54

    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);
    
    0 讨论(0)
  • 2020-12-24 11:55

    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>
    
    0 讨论(0)
提交回复
热议问题