0
votes

I added a native launch screen for dark and light mode, so when my device in night mode the background color of the launch screen is black and when the device in light mode the color is white.

The problem is:

I want to make the color depend on the user, if user's device in night mode and he choose the light mode inside my app the background color of the launch screen must be white

more explain:

If the device in night mode and my app theme is light mode the launch screen background color should be white (depend on the application theme not on the device)

how can I achieve this from native code?

1

1 Answers

1
votes

You can add the below tag to the root element in your native splash screen xml.

android:forceDarkAllowed="false"

This flag will ignore the System dark mode.

Now To enable/disable Night mode for a single activity you can use below code in your OnCreate method before super.onCreate method call:

getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_NO); // Disabled
getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_YES); // Enabled