question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[MaterialDatePicker] Button colors are not showing correctly

See original GitHub issue

Description: 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: image

API 29: image

API 30: image

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

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:closed
  • Created 10 months ago
  • Reactions:1
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
dsn5ftcommented, Dec 8, 2022

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.

2reactions
dsn5ftcommented, Dec 7, 2022

@leinardi I have a couple of potentially interesting findings:

  1. I was able to simplify / minimize your diff a bit to reproduce the issue (https://github.com/dsn5ft/basic-m3-compose-with-mdc/compare/main...splash-screen-setup)
  2. I made a separate minimal M3 project without Compose, so basically just combining the MDC and SplashScreen setup, and was also able to reproduce the issue there. So this seems to have nothing to do with Compose.
  3. If I move the WindowCompat.setDecorFitsSystemWindows(window, false) to be before super.onCreate(savedInstanceState), it seems to get rid of the issue. Although now that I think about it, I’m not sure if WindowCompat.setDecorFitsSystemWindows(window, false) has to be after onCreate 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?
Read more comments on GitHub >

github_iconTop Results From Across the Web

Android change colour of datepicker bottom button bar
Show activity on this post. All I want to do now is set the bottom button bar style/colour to black. I also tried...
Read more >
Problem with background and text color of buttons #523 - GitHub
it is always not visible. I can see though that when it is pressed, the color of the text is pink (the accent...
Read more >
Material datepicker dialog in android studio | Date picker
In this video we are going to learn how to create material date picker in android studioIf you have any questions or queries...
Read more >
MaterialButton - Android Developers
The widget will display the correct default Material styles ... For unfilled buttons, this class uses ?attr/colorPrimary for the text color ...
Read more >
Angular Material Datepicker: Complete Guide
Without this directive applied properly to the HTML input, the input component will not work correctly. Adding a modal calendar to the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found