Material Design progressdialog

后端 未结 2 862
清酒与你
清酒与你 2021-02-13 03:51
 alertDialog = new ProgressDialog(this);                          
 alertDialog.setMessage(getResources().getString(R.string.loader));
 alertDialog.setCancelable(false);         


        
相关标签:
2条回答
  • 2021-02-13 04:13

    This question is a bit old, but if you are using AppCompat, just add this attribute:

    <item name="android:tint">@color/my_color_accent</item>
    

    In your style

    <style name="MaterialDialog" parent="Theme.AppCompat.Light.Dialog">
        <item name="android:tint">@color/my_color_accent</item>
    </style>
    

    Hope this helps!

    0 讨论(0)
  • 2021-02-13 04:23

    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".

    0 讨论(0)
提交回复
热议问题