Tomas M
Tomas M

Reputation: 307

How to disable or program dark/night mode in Android Studio?

I want to know if it is possible to disable night/dark mode into android studio´s apps because, in my case, it breaks my app´s aesthetic.

I´ve tried using this code line into all my activities but it didn´t work:

setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);

If there aren´t any way to disable night/dark mode, can you tell me what do i have to do in order to make my app respond properly to color changes due to night/dark mode? (This includes background colors, drawable´s shapes colors and every color that gets modified by this mode)

(I accept documentation or any kind of information that can helps me solving this BIG problem)

My styles.xml:

<resources>

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

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light">
    <item name="android:padding">7dp</item>
</style>

</resources>

Upvotes: 4

Views: 8353

Answers (1)

Tomas M
Tomas M

Reputation: 307

Finally solved the problem disabling dark/night mode. We have to add the following code into our AppThemes:

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

Upvotes: 3

Related Questions