Search code examples
androidandroid-appwidgetandroid-dark-theme

Force app widget's light theme on OnePlus phone with Android 12


I have a problem with forcing a light theme of home screen app widget on OnePlus 9 phone with Android 12 (using the OnePlus' launcher). My widget's theme inherits from Theme.MaterialComponents.Light and is light on Android 11 and below, even when the phone is in the dark mode.

Problem is on Android 12, where the widget's background is always very dark, when the phone is in the dark mode. When I set pure white background, it ends-up almost black. Pure red is dark red, pure green is dark green, etc. Looks like something in the system is tinting the background colors. The same is happening with Theme.Material3.Light and @android:style/Theme.DeviceDefault themes.

Everything is good on pure Android in an emulator, so this looks like a OnePlus issue. Any ideas what can be wrong and how to fix this?


Solution

  • Goto to your themes file and place the following line in the style you are using for your app.

    <item name="android:forceDarkAllowed">false</item>