
No XML file said white, yet the dialog buttons vanished: three places a theme colour leaked
Invisible button text in an Android dialog or bottom sheet often means the app bar colour is leaking through the theme. Override the theme for that window only, and measure contrast on the shown view.
In SugarSpeller, our Korean spelling app, the Cancel and OK buttons on a delete confirmation were drawn almost white on a white dialog. The contrast ratio was 1.02:1, far below the 4.5:1 that body text needs. When we fixed it on September 16, 2026, no layout XML set that text to white: the theme colour picked to keep the app bar light had flowed into the button labels.
Eleven days later the same colour came back in two new bottom sheets, and this time it only showed up on a Galaxy S21 running the release build. The first fix had covered dialogs only; the correction sheet's test only checked that the text colour matched the intended one, and the mini window's test did not check colour at all. If your app uses its app bar colour as the theme's primary colour, any new dialog or sheet can leak the same way.
Contents (5)
- The app bar colour reached button text in three places
- The first test read XML; the rewrite reads the shown button
- The highlight colours kept their hue; only lightness moved
- Measuring contrast on the shown view, step by step
- Two places the overlay doesn't reach: NoActionBar and the framework AlertDialog
The app bar colour reached button text in three places
At 13:25 KST on September 16 the operator reported that the buttons on the activity-history delete popup were white and unreadable in light mode. The agent (Claude) followed the style definitions in Material Components 1.14.0, Google's Android UI library, and found that the button text colour ends in a single theme attribute:
AlertDialog button
→ buttonBarButtonStyle
→ Widget.MaterialComponents.Button.TextButton
→ mtrl_text_btn_text_color_selector (enabled colour)
→ ?attr/colorPrimary
colorPrimary is the theme's main colour slot, and our app theme (AppTheme) put the app bar colour there: #fafdff in light, black in dark. Black on the white dialog is 21:1, which is why only light mode broke.
Changing the global colorPrimary would have recoloured the app bar, so that was out. Our accent blue only reaches 3.80:1 on white, short of the bar. The first fix added a theme overlay that applies to dialog windows only, alertDialogTheme, in both light and dark, and inside it overrode just colorPrimary with a darker blue. The overlay keeps the original dialog theme as its parent.
The two screens added on September 27 picked up the same colour another way. The correction sheet that opens when you tap a coloured word and the mini window behind the text-selection menu are both BottomSheetDialogs, panels that slide up from the bottom, and both inflated their content (built view objects from layout XML) with the activity context. Views inflated that way never pass through the sheet's theme overlay, so they read colorPrimary straight from the activity's AppTheme. The fill of the "Why is this wrong?" button and the text of OK, Copy correction and Open in app all came out #fafdff, 1.00 to 1.02:1 on the white sheet.
Dark mode had one more cause. This app's dark AppTheme also inherits from a light theme (Theme.MaterialComponents.Light), so the correction sheet stayed white in dark mode, and the correction text colours made brighter for dark mode sat on it at 3.2:1. The mini window was the reverse: a dark #212121 surface, but its result text took the theme's default black (1.30:1 by our calculation).

The fix was to inflate the sheet content with the sheet's own context (dialog.context) and add a sheet-only overlay (bottomSheetDialogTheme) to AppTheme that sets the sheet surface and a dedicated button colour. On September 28 the correction sheet was fixed first, together with the overlay; twenty-one minutes later the mini window, already under that overlay, only needed its context and button colour changed.
The first test read XML; the rewrite reads the shown button
The test in the first commit (13:54) read resource XML as text: it checked that the overlay line existed and that the button colour value cleared 4.5:1 on white. The white text only exists after the theme resolves its attributes at runtime, so a check on XML values can't see this bug.
At 14:10 the operator asked whether everything had really changed and told the agent to cross-check before release. Only then did the agent write a Robolectric test (Robolectric runs Android code on the JVM without a device), on the grounds that what the XML says and what the widget draws are different things. The test builds a dialog on a context themed with AppTheme, calls show() and reads the colour each button actually draws (currentTextColor). With the one overlay line deleted from the light theme, the original symptom came back as numbers:
OK #fafdff on #ffffff = 1.02:1 FAIL
Cancel #fafdff on #ffffff = 1.02:1 FAIL
buttons readable in dark mode pass
The September 27 correction sheet did ship with a Robolectric test, but it only compared the corrected word's currentTextColor with the intended red highlight colour. If the colour matches, the test passes whether that word sits on a white sheet or a dark one. After the September 28 check on the S21, the rewritten test first reads the sheet's real surface colour (the first check argument is a Korean label meaning "correction, type colour"):
// sheet surface view
val sheet = dialog.findViewById<View>(com.google.android.material.R.id.design_bottom_sheet)
// fill colour of the sheet's background shape
val bg = (sheet.background as MaterialShapeDrawable).fillColor!!.defaultColor
check("교정(유형 색)", dialog.findViewById<TextView>(R.id.correction_corrected).currentTextColor, bg, 4.5)
It measures the sheet's text and buttons this way, in light and dark. Filled buttons get two checks: text on fill at 4.5:1 and fill on sheet at 3:1. Measure theme colour bugs from the shown view's currentTextColor and the surface actually behind it, not from XML values.
The highlight colours kept their hue; only lightness moved
A separate problem, one the agent had flagged four minutes before the dialog report, was in the spelling highlights, where colour tells the user the error type: red for spelling, teal for spacing, blue for statistics-based corrections, orange for possible non-standard words, and violet for a type that Naver (Korea's largest portal, whose checker the app calls) marks separately. The dark-mode colour folder (values-night) defined none of the five, so dark mode used the light values, and violet on the #212121 background was 2.70:1.
At 13:21, answering the operator's question about whether anything else needed testing, the agent flagged that violet and said a single lighter violet for dark mode would fix it. That clears the bar easily, but in HSL the hue turns by nearly 5 degrees and saturation goes to 100%, a different violet. When the operator asked for a proper fix, the agent added all five dark values but changed only orange in light mode, leaving red, teal and blue as they were and keeping red and teal as the app's familiar colours.
At 13:40 its own 4.5:1 test failed all three, and the agent reported that the test had refuted its judgement. In the output, temp1 is blue, temp2 teal and temp4 red:
light/temp1 #3982ff on #fafdff = 3.54:1
light/temp2 #009a9a on #fafdff = 3.38:1
light/temp4 #ee4b4b on #fafdff = 3.58:1
Only light violet and dark orange stayed as they were; the other eight values (the seven under 4.5:1, plus dark teal at a thin 4.67:1) kept their hue and moved lightness only: darker for light mode, lighter for dark. Recomputed, the largest hue shift is 0.2 degrees (blue). The agent first computed values that landed just over 4.5:1, then retargeted dark mode at 5.0:1 for some margin.

The first fix's commit message records the decision as "red stays red, green stays green" (its green is the teal above). Don't rotate the hue of a colour that means something. Move lightness, and define the value in both values and values-night. On the web side we search for dark text colours the same way, one lightness percent at a time, as described in Measuring 4.5:1 colour contrast in the site build.
Measuring contrast on the shown view, step by step
- Follow the widget style of the unreadable text until it ends. If it ends in a theme attribute such as
?attr/colorPrimary, check whether that attribute holds a colour chosen for something else (here, the app bar). - Leave the global theme colour alone and override it for that window only (
alertDialogTheme,bottomSheetDialogTheme). Inflate the content withdialog.context. The dialog side looked like this:<!-- inside AppTheme (both values and values-night) --> <item name="alertDialogTheme">@style/AlertDialogTheme</item> <style name="AlertDialogTheme" parent="ThemeOverlay.MaterialComponents.Dialog.Alert"> <item name="colorPrimary">@color/dialog_button_text</item> <!-- #0063c6 --> </style> - Check that every theme the manifest names gets the overlays, and that no
parent="Theme.…"cuts it off from the theme before the dot. - For colours that carry meaning, lock the HSL hue and move lightness, finding light and dark values separately.
- In Robolectric,
show()the screen and measurecurrentTextColoragainst the real surface (for a sheet, thefillColorof itsMaterialShapeDrawable) in light and dark. - Revert one line of the fix and confirm the test fails with the original number, 1.02:1 in our case. On September 16, six such reverts were all caught.
- Install the release APK on a real device and open each new screen once in light and dark.
Each screen needs its own measuring test, so a new screen without one surfaces on a device first, as the sheets did on September 28. That day's S21 check is in AI code review: fix only what survives refutation. Robolectric does not reproduce device rendering, and this app is built from XML views; we have not measured Jetpack Compose screens.
Two places the overlay doesn't reach: NoActionBar and the framework AlertDialog
At 14:19 on September 16, while matching every dialog call to its manifest theme, the agent flagged one more thing. AppTheme.NoActionBar reads like a child of AppTheme, but it is declared with parent="Theme.AppCompat.NoActionBar". In Android styles, an explicit parent attribute replaces the inheritance implied by the dotted name. This theme therefore carries neither of the two overlays.
One screen uses it: the launch screen. Its version and permission popups are a custom-layout window that never touches colorPrimary, so nothing has leaked there yet. The changelog for app version 1.6.018 warns that adding an AlertDialog to that screen would bypass the fix, and on November 10 the parent was unchanged.
The September 16 audit counted three places that build a dialog (activity-history delete, greeting cards, the subscription screen) as covered because all ran under AppTheme. Only the activity-history one, the dialog in the report, was an androidx dialog; the other two used the framework's built-in android.app.AlertDialog. The greeting-card call has since been removed, but on the remote develop branch as of November 10 one call on the subscription screen (shown only when a user holds more than one subscription) is still the framework class. The September 16 measuring test shows the androidx dialog, so that one call's button colour has not been measured on a shown dialog yet.
As of November 11, 2026. Based on the SugarSpeller repository history, the 1.6.018 changelog and the September 16 session log; contrast ratios were recomputed with the WCAG relative-luminance formula. The current state is as of the remote develop branch on November 10.
This note is written from values SugarMount measured itself; an AI coding agent was used to draft it.