0

I want to create a ProgressDialog with custom color but I want to keep the original format of the circular. I also don't want to change the color accent because it will also change other component color like Switch...

Please help me to solve this problem.

Thanks.

Glenn
  • 71
  • 3
  • 9

2 Answers2

0

You can use a custom drawable for this. Replace colorAccent and other colors with your colors.

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="0"
    android:pivotX="50%"
    android:pivotY="50%"
    android:toDegrees="1440" >

    <shape
        android:innerRadiusRatio="3"
        android:shape="ring"
        android:thicknessRatio="15"
        android:useLevel="false" >

        <size
            android:height="75dip"
            android:width="75dip" />

        <gradient
            android:angle="0"
            android:endColor="@color/colorAccent"
            android:centerColor="@color/colorAccentCenter"
            android:startColor="@color/colorAccentCenter"
            android:type="sweep"
            android:useLevel="false" />

    </shape>

</rotate>
vidulaJ
  • 1,232
  • 1
  • 16
  • 31
0

you can write a style in style.xml under v21 folder like below:

<style name="ProgressBar" parent="Base.Widget.AppCompat.ProgressBar"> <item name="android:colorAccent">@color/red</item> </style>

and use it like this

ProgressDialog myProgressDialog = new ProgressDialog(MyActivity.this); myProgressDialog.setProgressStyle(R.style.ProgressBar) myProgressDialog.show();

masoud vali
  • 1,528
  • 2
  • 18
  • 29