Isaac Qadri
Isaac Qadri

Reputation: 67

Delete the night mode in my android application | android studio

I do not want the night mode in my application, I tried to delete a file themes.xml (night), But that didn't work, I also tried moving the themes.xml file content to a themes.xml (night) And it didn't work either.

themes.xml file

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

Can you help me thanks!.

Upvotes: 2

Views: 2039

Answers (2)

Apps Maven
Apps Maven

Reputation: 1420

Please use default app theme in style file instead of "Theme.AppCompat.DayNight.NoActionBar". Night mode will not work unless we use the Day Night theme in style. There for you can use default theme for your application to disable the dark mode.

<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>

Upvotes: 4

Nour Eldien Mohamed
Nour Eldien Mohamed

Reputation: 961

try add this

<style name="Theme.MyApp" parent="Theme.MaterialComponents.Light.DarkActionBar">

then this in layout

android:forceDarkAllowed="false"

Upvotes: 0

Related Questions