diff --git a/tns-core-modules/ui/dialogs/dialogs-common.ts b/tns-core-modules/ui/dialogs/dialogs-common.ts index ea01f1546..fbf106cbb 100644 --- a/tns-core-modules/ui/dialogs/dialogs-common.ts +++ b/tns-core-modules/ui/dialogs/dialogs-common.ts @@ -60,6 +60,18 @@ export function getButtonColor(): color.Color { return buttonColor; } +var buttonBackgroundColor: color.Color; +export function getButtonBackgroundColor(): color.Color { + if (!buttonBackgroundColor) { + var btn = new button.Button(); + applySelectors(btn); + buttonBackgroundColor = btn.backgroundColor; + btn.onUnloaded(); + } + + return buttonBackgroundColor; +} + var textFieldColor: color.Color; export function getTextFieldColor(): color.Color { if (!textFieldColor) { diff --git a/tns-core-modules/ui/dialogs/dialogs.android.ts b/tns-core-modules/ui/dialogs/dialogs.android.ts index 083d5c15a..619168bf6 100644 --- a/tns-core-modules/ui/dialogs/dialogs.android.ts +++ b/tns-core-modules/ui/dialogs/dialogs.android.ts @@ -41,15 +41,22 @@ function showDialog(builder: android.app.AlertDialog.Builder) { } let buttonColor = dialogsCommon.getButtonColor(); - if (buttonColor) { + let buttonBackgroundColor = dialogsCommon.getButtonBackgroundColor(); + if (buttonColor || buttonBackgroundColor) { let buttons : android.widget.Button[] = []; for (let i = 0; i < 3; i++) { let id = dlg.getContext().getResources().getIdentifier("android:id/button" + i, null, null); buttons[i] = dlg.findViewById(id); } + buttons.forEach(button => { if (button) { - button.setTextColor(buttonColor.android); + if (buttonColor) { + button.setTextColor(buttonColor.android); + } + if (buttonBackgroundColor) { + button.setBackgroundColor(buttonBackgroundColor.android); + } } }); }