Material-dialogs: Change action button colors

Created on 15 Apr 2019  路  11Comments  路  Source: afollestad/material-dialogs

Library Version:

2.7.0

Affected Device(s):

Google Pixel with Android 9.0

Describe the Bug:

Button colour is not changed.

To Reproduce:

MaterialDialog(context).title(R.string.ok)
    .positiveButton(R.string.ok) { whatever() }
    .apply {
        getActionButton(WhichButton.POSITIVE).updateTextColor(Color.BLUE)
    }
    .show()

Button colour is still black

Expected Behavior:

Button colour should be blue

improvement core

Most helpful comment

Everyone who want to change button color programmatically you can use this :

onShow{ it?.getActionButton(WhichButton.NEGATIVE).updateTextColor(Color.GRAY) }

All 11 comments

+1 #1782

@mac229 action button colors should be changed from your theme, not programatically.

https://github.com/afollestad/material-dialogs/blob/master/documentation/CORE.md#text-color

And the default value is whatever colorPrimary is in your theme.

I want to change the color of the button with code, like before, positiveColor (xxxx). What should I do?

i use this code for button color change

getActionButton(WhichButton.NEGATIVE).updateTextColor(Color.BLACK)

but that is not effect

In some cases there can be multiple dialogs in the same activity with different colored buttons because that's what the designers want. Would be nice to have this API working as expected

Any updates on this, upgraded recently from 0.9.6.0 and refactored all of my code in over 48 different places to see that there was no way to set individual action button colors/ripple/them. I very much appreciate going for the full bore Material spec, but wouldn't it make sense to be able to set a complete theme for dialogs based on ThemeOverlay.MaterialComponents/AppCompat.Dialog?

I also just finished an arduous migration and wasn't expecting this regression. My design requires some buttons to be a different color than the theme color.

@mac229 action button colors should be changed from your theme, not programatically.

https://github.com/afollestad/material-dialogs/blob/master/documentation/CORE.md#text-color

Sometimes I need to have a few different colors, but these apis don't work, so I rewrote one myself in response to these requirements.馃槀

In some cases there can be multiple dialogs in the same activity with different colored buttons because that's what the designers want. Would be nice to have this API working as expected

No need to go super far away with examples. Take a destructive action for example, such as "Delete".

Everyone who want to change button color programmatically you can use this :

onShow{ it?.getActionButton(WhichButton.NEGATIVE).updateTextColor(Color.GRAY) }

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dabo248 picture dabo248  路  7Comments

jlelse picture jlelse  路  6Comments

timbremer picture timbremer  路  6Comments

azizimusa picture azizimusa  路  4Comments

eygraber picture eygraber  路  3Comments