[MaterialDatePicker] Button colors are not showing correctly
See original GitHub issueDescription: The button colors are not showing correctly on API < 30. The text and background color are pink, like the color attribute from the theme was not set. But the rest of the UI of the Dialog seems fine.
API 25:
API 29:
API 30:
Expected behavior: Screenshots and/or description of expected behavior
Source code: The App theme is extending Theme.Material3.DayNight.NoActionBar
but it’s setting only colorPrimary
, colorPrimaryDark
and colorAccent
(since this is a Compose only app, I’m trying to keep the XML theme attributes to the minimum).
Minimal sample app repro: Repro project available here: https://github.com/leinardi/Forlago/tree/date-piker
- Theme defined here: https://github.com/leinardi/Forlago/blob/date-piker/modules/library-ui/src/main/res/values/themes.xml
- Date picker shown here: https://github.com/leinardi/Forlago/blob/date-piker/modules/feature-foo/src/main/kotlin/com/leinardi/forlago/feature/foo/ui/foo/FooScreen.kt#L133
- Date picker defined here: https://github.com/leinardi/Forlago/blob/date-piker/modules/library-ui/src/main/kotlin/com/leinardi/forlago/library/ui/component/DatePicker.kt#L50
Android API version: The issue happens on API < 30 (tested on 29 and 25)
Material Library version: 1.7.0
Device: Emulator (Nexus 5)
Issue Analytics
- State:
- Created 10 months ago
- Reactions:1
- Comments:11 (6 by maintainers)
Top GitHub Comments
Great! Actually, looking at the SplashScreen guide it seems like the
installSplashScreen
call is meant to be before onCreate():https://developer.android.com/develop/ui/views/launch/splash-screen/migrate#migrate_your_splash_screen_implementation
And looking at the edge-to-edge guide, the
setDecorFitsSystemWindows
is supposed to be after onCreate():https://developer.android.com/develop/ui/views/layout/edge-to-edge
I tried this in my sample app and that setup fixes the issue as well.
Also, I chatted with someone who works on the SplashScreen library, and they confirmed the above setup is correct. This issue had something to do with the timing of the DecorView creation in PhoneWindow and the theme inflation, so the order with respect to onCreate() is important.
@leinardi I have a couple of potentially interesting findings:
WindowCompat.setDecorFitsSystemWindows(window, false)
to be beforesuper.onCreate(savedInstanceState)
, it seems to get rid of the issue. Although now that I think about it, I’m not sure ifWindowCompat.setDecorFitsSystemWindows(window, false)
has to be afteronCreate
in order to do anything? I can’t really tell in my project. Can you try in your projects and see if a) that fixes the issues and b) it’s still going edge-to-edge as you expect?