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.

[Theme.Material3.Light] 'DynamicColors.applyToActivitiesIfAvailable()' affect on 'forcedarkAllowed = true' behavior

See original GitHub issue

Hi, Description: The App use Theme.Material3.Light.NoActionBar theme with android:forceDarkAllowed = true attribute. Also applied ‘Dynamic Colors’ feature through DynamicColors.applyToActivitiesIfAvailable(). In-App colors don’t tailor to the enabled Dark Theme (exclude dialogs). With disabled ‘Dynamic Colors’ feature, all work fine. It is expected behavior?

Expected behavior: Colors must be changed according to the forceDarkAllowed = true attribute.

Source code:

<style name="MainTheme" parent="Theme.Material3.Light.NoActionBar">
        ...
      <item name="android:windowBackground">@android:color/white</item> -- stayed as is.
      <item name="android:forceDarkAllowed">true</item>
        ...
    </style>

Android API version: 31

Material Library version: 1.5.0-rc01 or 1.6.0-alpha01

Device: Pixel 4a

Thanks.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
VicMikhailaucommented, Jan 18, 2022

@dsn5ft I see my misstep. I have used DynamicColors.applyToActivitiesIfAvailable() and solution above simultaneously. Thanks again!

1reaction
dsn5ftcommented, Jan 18, 2022

Hmm the Activity background seems to be automatically switching to dark as expected for me, so not sure what the difference with your app is:

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Theme.Material3.Light] 'DynamicColors ... - IssueHint
applyToActivitiesIfAvailable ()' affect on 'forcedarkAllowed = true' behavior. ... Light.NoActionBar theme with android:forceDarkAllowed = true attribute.
Read more >
MDC-Android – Material Design 3
Apply dynamic color using Material Design 3 for AndroidCodelab with step-by-step instructions for adding dynamic color features to an app. Material Design ...
Read more >
Dark theme - Android Developers
Makes it easier for anyone to use a device in a low-light environment. Dark theme applies to both the Android system UI and...
Read more >
An Android Material Design 3 Theming and Dynamic Color ...
Review the color scheme in the Your Theme panel and make any ... to the applyToActivitiesIfAvailable() method of the DynamicColors class.
Read more >
Implementing Dark theme in your Android Application
And if you haven't already updated your app to support Dark theme, your app ... Light"> <item name="android:forceDarkAllowed">true</item>
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