Home > Enterprise >  How to disable dark mode in android 9
How to disable dark mode in android 9

Time:10-19

i am trying to disable dark mode in my app and its working on android 10 or higher but its not working on android 9. Can anyone please help me out here. Thanks in advance.

In on create method i have done below, in theme or theme(night), in both files i placed

<style name="Theme.VideoTradieProvider" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!--    <style name="Theme.VideoTradieProvider" parent="Theme.MaterialComponents.Light.NoActionBar">-->
        <!-- Primary brand color. -->

        <item name="android:windowActivityTransitions">true</item>

<!--        <item name="android:windowEnterTransition">@transition/explode_old</item>-->
<!--        <item name="android:windowExitTransition">@transition/explode_old</item>-->

        <item name="colorPrimary">@color/purple_500</item>
        <item name="colorPrimaryVariant">@color/purple_700</item>
        <item name="colorOnPrimary">@color/white</item>

        <!-- Secondary brand color. -->
        <item name="colorSecondary">@color/teal_200</item>
        <item name="colorSecondaryVariant">@color/teal_700</item>
        <item name="colorOnSecondary">@color/black</item>
        <!-- Status bar color. -->
        <item name="android:statusBarColor" tools:targetApi="l">@color/white</item>
        <item name="android:windowLightStatusBar">true</item>
        <!-- Customize your theme here. -->
    </style>

also write below line but not working with anroid 9

AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)

CodePudding user response:

Change the parent attribute of your app style in themes.xml from

<style name="Theme.AppName" parent="Theme.MaterialComponents.DayNight.NoActionBar">

to

<style name="Theme.AppName" parent="Theme.MaterialComponents.Light.NoActionBar">

CodePudding user response:

Is it Right As Josh and another way to see if You have the theme(night) then delete it

  • Related