1

I'm using Material theme. I want my app to be only in light theme (For now we don't have any plans for dark mode). Some devices force dark mode on apps and I want to avoid that.

I have seen this post on SO and unfortunately it doesn’t work for me.

So, how to solve this?

Styles.xml

   <resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="materialButtonStyle">@style/ButtonTheme</item>
    </style>

    <style name="LandingTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/White</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="android:buttonStyle">@style/ButtonTheme</item>
    </style>
</resoures>
null_override
  • 467
  • 3
  • 10
  • 30

1 Answers1

2

Update: Some OEMs provide a dark-mode feature on an individual-app basis, which basically doesn't respect the forced-dark mode setting.

In that case, it is best to ignore any issues that relate to it. The user is warned about theming incompatibilities, which is a good thing from their side at the very least, if not respecting this setting.


Please do not account for uncontrollable factors such as overriding the force dark mode option (available inside Developer Options from Android 10+), which makes the opt-in/out effectively useless.

The feature is more of a trial-and-error, replacing light elements with their dark counterparts (basic but vague explanation, agreed) which may make-or-break an Application's User Experience.

There's a reason why it is meant only for Developers, and not made available as a "User" feature.

Arvind
  • 724
  • 5
  • 6
  • Actually I am not looking for that ( Overriding the force dark mode option of developer options). I'm looking for overriding the dark mode which is on Settings (the default one not developer options) – null_override Oct 20 '20 at 07:45
  • 1
    I don't think enabling Dark Mode in System "forces" an app to go Dark. In fact, Developers have to implement `DayNight` themes in order to follow system's dark mode setting - [source](https://developer.android.com/guide/topics/ui/look-and-feel/darktheme#supporting_dark_theme_in_your_app). – Arvind Oct 20 '20 at 14:12
  • Thanks a lot for the link! In my particular case, enabling darkmode on my Xiaomi phone results in the app being in dark mode. May be it's an OEM issue? – null_override Oct 20 '20 at 14:33
  • Ah, seems that this MIUI feature doesn't respect the setting. Well, that's OEM Aggressiveness for you. – Arvind Oct 20 '20 at 14:37
  • You can safely ignore this, since there's nothing that can be done about it. It's "force dark mode" just pulled out of Developer Options. – Arvind Oct 20 '20 at 14:40
  • May be that's the only option :( – null_override Oct 20 '20 at 14:41
  • At least they warn the user about incompatibility issues, which makes it easier for you for pointing out that it cannot be termed as an issue. – Arvind Oct 20 '20 at 14:44