Hay,
Is there a simple way to change the title
and the text
colour without changing the primary colour of the whole app?
Here is what I got now:
I dont want to change the textColorPrimary
First, create a style definition like this:
<style name="DialogTheme" parent="ThemeOverlay.AppCompat.Dialog">
<item name="android:textColorPrimary">your color here</item>
</style>
Then, when you create the dialog, instead of using the AlertDialog.Builder(Context)
constructor, use the AlertDialog.Builder(Context, int)
method and pass a reference to your style:
new AlertDialog.Builder(this, R.style.DialogTheme)
.setTitle("Hello world")
.setMessage("some longer text for the body of the dialog")
.show();
Even though this depends on changing textColorPrimary
, it doesn't do so in a way that affects anything else in your app.
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