2

How to change ProgressDialog style in Android? I need to change background color, and text color.

I have my one style in my app, what item I must override to change progress dialog style?

I would like to change style using only xml, without coding. It is possiable?

PS:

I have no progress bar! I have progress dialog. And i would like to change it style using styles and themes, like I changes style for listview, windows backgrounds and etc.

Nik
  • 7,114
  • 8
  • 51
  • 75

2 Answers2

9

You can change the theme of the ProgressDialog like this:

ProgressDialog dialog = new ProgressDialog(this, AlertDialog.THEME_HOLO_DARK);
dialog.setTitle("Title");
dialog.setMessage("Message");
dialog.show();
Groppe
  • 3,819
  • 12
  • 44
  • 68
  • I want to change the color of my progressDialog to orange and I mean changing just the rotating circle color not background or text etc , your code seems the correct approach, can you also give me a hint on the xml file. Thanks very much – m0j1 May 23 '15 at 08:08
  • @m0j1 there are some good answers on this question that could work: http://stackoverflow.com/questions/5337613/how-to-custom-circular-progress-bar-color – Groppe May 26 '15 at 14:07
3

code for custom dialogbar: File under drawable declares the colors of the different states:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:id="@android:id/background">
        <shape>
            <gradient
                    android:startColor="#000001"
                    android:centerColor="#0b131e"
                    android:centerY="0.75"
                    android:endColor="#0d1522"
                    android:angle="270"
            />
        </shape>
    </item>

    <item android:id="@android:id/secondaryProgress">
        <clip>
            <shape>
                <gradient
                        android:startColor="#234"
                        android:centerColor="#234"
                        android:centerY="0.75"
                        android:endColor="#a24"
                        android:angle="270"
                />
            </shape>
        </clip>
    </item>

    <item android:id="@android:id/progress">
        <clip>
            <shape>
                <gradient
                    android:startColor="#144281"
                    android:centerColor="#0b1f3c"
                    android:centerY="0.75"
                    android:endColor="#06101d"
                    android:angle="270"
                />
            </shape>
        </clip>
    </item>

</layer-list>

Code inside your layout xml:

<ProgressBar android:id="@+id/progressBar"
    android:progressDrawable="@drawable/progress_bar_states"
    android:layout_width="fill_parent" android:layout_height="8dip" 
    style="?android:attr/progressBarStyleHorizontal" 
    android:indeterminateOnly="false" 
    android:max="100">
</ProgressBar>
Narendra
  • 1,868
  • 6
  • 25
  • 39
  • I have no progress bar! I have progress dialog. And i would like to change it style using styles and themes, like I changes style for listview, windows backgrounds and etc. – Nik Apr 20 '12 at 07:54