Android Studio Disable Dark Mode How to Disable Dark Mode in Android App Programmatically

Android Studio Disable Dark Mode How to Disable Dark Mode in Android App Programmatically. How to Disable Dark Mode in Android Studio App, Disable Night Mode in android studio programmatically.

Dark mode has become a popular feature among Android users in recent years, offering a more comfortable viewing experience in low light environments. However, there may be instances where you need to disable dark mode in your Android app. In this article, we’ll discuss how to disable dark mode in an Android app programmatically.


This post is all about:

android studio disable dark mode

how to disable dark mode android studio
how to disable dark mode in android programmatically

android disable dark mode programmatically

how to turn off dark mode in android studio

android studio disable night mode

disable dark mode android studio,

android studio dark mode off

android disable dark mode for app

how to make android studio dark mode

how to enable dark mode in android studio

disable dark mode for specific app android studio

If you are a developer, working on a project and you want to disable dark mode or night mode from your app. You are in the right place. In this post, we will discuss briefly disabling night mode from your app. I will show you the complete guide in detail. How to disable night mode programmatically or disable dark mode programmatically in android app.

We have 3 methods which I’m going to explain here briefly. Method One is for API level 29 or above. Method Two is for below API level 29 and Method Three can be used for all API levels.

Disabling dark mode or disabling night mode in the android studio is a very easy task. so let’s get started.

Few things that you should know before we dive into the Main Course

  1. Method 1 is working only on API level 29 or above.
  2. Method 2 is working on all APIs but we prefer it to use lower than API 29.
  3. You should know on which API level you are making your project.
  4. These methods will be implemented programmatically.
  5. Method 3 also works on all API levels and we use it more than method 2 because it is easy to implement.

Let’s Start

Android Studio Disable Dark Mode. How to Disable Dark Mode in Android App Programmatically. Disable Dark Mode Android Studio

Method 1:

The steps that we need to follow in method one are:

Step 1: Open your Project then go to Project Structure which is located on the left upper side. (See Image below)

  1. Click on Project which is where number 1 is printed.
  2. After that click on number 2 which is where android is selected, if you didn’t find the android then you have to click on whatever option it is, it will show a drop-down menu and then select android from it.
  3. Then select the app folder that is number 3.
  4. After that select the res folder which is number 4.
  5. Now select the values folder that is number 5.
  6. After that select the themes folder and then themes.xml (night) which is number 6.
Disable Dark Mode in Android Studio App

Step 2: Double-click on themes.xml (night file).

Step 3: Copy and paste the below code in between style tags of themes.xml (night).

Android Studio Disable Dark Mode How to Disable Dark Mode in Android App Programmatically. Disable dark mode android studio
Click on the image to enlarge it.
//API 29 and above (While Pasting the code delete this comment)

<item name="android:forceDarkAllowed" tools:targetApi="q">false</item>

Step 4: Re-build your project or Apply Changes to your app.

Note: This method is only for API Level 29 or above.


Android Studio Disable Dark Mode. How to Disable Dark Mode in Android App Programmatically. Disable Dark Mode Android Studio Method 2:

The steps that we need to follow in method two are:

Step 1: Copy the Code Below

//Below API 29 (While Pasting the code delete this comment)

AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);

Step 2: Paste the copied code in every activity file’s onCreate Method.

Android Studio Disable Dark Mode How to Disable Dark Mode in Android App Programmatically. Disable dark mode android studio
Click on the image to enlarge

Note: You need to put the code in every activity onCreate Method(), it will work only for those activities in which code is pasted otherwise dark mode will not be disabled completely.


Android Studio Disable Dark Mode. How to Disable Dark Mode in Android App Programmatically. Disable Dark Mode Android Studio Method 3:

The steps that we need to follow in method three are:

Step 1: Follow steps 1 and step 2 of Method one. Open theme.xml (night).

Step 2: Change the parent theme to a Light theme

//Disable Dark Theme in app
<style name="Theme.DarkTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">

Step 3: Paste the Code in theme.xml (night) and Apply Changes.


Disable Dark Mode in Android Studio App
Click on the image to enlarge it.

Hurray, you have mastered Android Studio Disable Dark Mode How to Disable Dark Mode programmatically in android

In this article, we discussed how to disable dark mode in an Android app programmatically. By using the setDefaultNightMode() method of the AppCompatDelegate class, we were able to disable dark mode in the app. Remember to test your app thoroughly to ensure that it works correctly in both light and dark mode.

What is Disable dark mode in Android app programmatically

Disabling dark mode in an Android app programmatically means that you are writing code to prevent the app from switching to the dark theme when the device’s system-wide dark mode is enabled. By default, Android 10 and above support system-wide dark mode, and many apps have already implemented support for it. However, there may be instances where you need to disable dark mode in your app, such as when you want to ensure consistent branding or if the dark theme conflicts with the app’s UI design.

To disable dark mode in an Android app programmatically, you can use the AppCompatDelegate class provided by the Android Support Library. The setDefaultNightMode() method of this class can be used to specify the default night mode for your app. By passing the MODE_NIGHT_NO parameter to this method, you can disable dark mode in your app.

It’s important to note that disabling dark mode in your app may affect the user experience, especially in low light environments. It’s always recommended to thoroughly test your app to ensure that it works correctly in both light and dark mode before disabling dark mode programmatically.

Click here to view a short video on disabling dark mode in android studio


Watch the video on Youtube:


For more tutorials on android studio Click Here

Why do we need to disable dark mode

Well, there is no specific reason. Some developers do it because they don’t like the night mode or dark mode. In dark mode sometimes apps don’t give users a premium look and feel. Some think about it as a headache to provide a look for both light mode and dark mode, it is a little bit time-consuming. We tried our best to provide you with the best high-quality content. If you like our work please do support us by sharing it with others.

Leave a Comment