My app extends Theme.AppCompat.Light
and the material-styled dialogs appear with white background, black text color, and green buttons (spinner in ProgessDialog
is also green).
I would like to change the color and font of the text, and also the color of the buttons and spinner.
How can I do it?
I found this post but the XML solution doesn't work for me and the other answers are third party libs that don't have a ProgressDialog
.
Thanks!
So whenever you want to change the color of AlertDialog box, just change color in styles. xml and all the dialog boxes will be updated in the whole application.
This class was deprecated in API level 26. ProgressDialog is a modal dialog, which prevents the user from interacting with the app. Instead of using this class, you should use a progress indicator like ProgressBar , which can be embedded in your app's UI.
In android there is a class called ProgressDialog that allows you to create progress bar. In order to do this, you need to instantiate an object of this class. Its syntax is. ProgressDialog progress = new ProgressDialog(this);
Using the Custom Progress Dialog To use it, declare the class CustomProgressDialog at the beginning of your Activity: class MainActivity : AppCompatActivity() { private val progressDialog by lazy { CustomProgressDialog(this) } override fun onCreate(savedInstanceState: Bundle?) { super.
To have the whole "Material Experience" you should use the latest AppCompat everywhere. Instead of android.app.AlertDialog
use android.support.v7.app.AlertDialog
to target devices < 21.
It is enough just to set your AppTheme up correctly like in the following:
<style name="AppTheme" parent="Base.AppTheme">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/accent</item>
<!-- This is the interesting part -->
<item name="android:dialogTheme">@style/AppTheme.Dialog</item>
<item name="dialogTheme">@style/AppTheme.Dialog</item>
<item name="android:alertDialogTheme">@style/AppTheme.Dialog</item>
<item name="alertDialogTheme">@style/AppTheme.Dialog</item>
</style>
<!-- Style the dialog like the normal AppTheme -->
<style name="AppTheme.Dialog" parent="Theme.AppCompat.Light.Dialog">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/accent</item>
</style>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With