Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Material Design progressdialog

 alertDialog = new ProgressDialog(this);                          
 alertDialog.setMessage(getResources().getString(R.string.loader));
 alertDialog.setCancelable(false);
 alertDialog.show();

Simply when I do this, green circle shows up with the word loading besides it. However when i DONT USE progress dialog, and i use a progressbar on the page I get a pink color as i have defined the below in my styles.xml

<item name="colorPrimary">@color/pink</item>
<item name="colorPrimaryDark">@color/pink</item>
<item name="colorAccent">@color/pink</item>

What is the solution of getting the circle pink color as in the progress bar on page?

like image 868
user3278732 Avatar asked Feb 15 '15 13:02

user3278732


1 Answers

For API 21+ you can define the following style to colour the material progress dialog. Note that this should be under values-v21 if you support lower platforms.

<style name="MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:alertDialogTheme">@style/MyAlertDialog</item>
</style>

<style name="MyAlertDialog" parent="android:Theme.Material.Light.Dialog.Alert">
    <item name="android:colorAccent">@color/pink</item>
</style>

<item name="colorAccent"> is for AppCompat whereas <item name="android:colorAccent"> is for API 21+. Material progress dialogs don't work with AppCompat, even with the new v22.1 Support lib AppCompatDialog.

You can see Chris Banes' answer here stating that he will not backport Progress Dialogs because they are "a bad pattern".

like image 143
Oguz Babaoglu Avatar answered Oct 17 '22 06:10

Oguz Babaoglu