0

To ignore the dark mode the only thing I am using is

    AppCompatDelegate.DefaultNightMode = AppCompatDelegate.ModeNightNo;

But it does not work well for me since when navigating to a WebView and returning the entries that I do not have configured with white backgroundcolor they turn black.

entry when entering the app -> 1

enter image description here

After navigating a web view and return -> 2

enter image description here

The instantiation of the entry

 var lastNameEntry = new Entry
            {
                Placeholder = "Apellido",
                TextColor = Color.Black,
                ReturnType = ReturnType.Next,
            };

The solution I have is to put BackGroundColor = Color.White in all the entries but is there any alternative to this?

SarPa
  • 35
  • 8
  • 1
    Create a `Style` with TargetType `Entry`, in your `App.xaml` "Resources" dictionary. Set desired properties there. NOTE: Where is that `DefaultNightMode` line? If it is in `All.xaml.cs` / `OnResume`, it should be applied when it returns to your app. [Other suggestions here](https://stackoverflow.com/q/64183173/199364). – ToolmakerSteve Jul 02 '22 at 21:50
  • I solved it by placing AppCompatDelegate.DefaultNightMode = AppCompatDelegate.ModeNightNo; in method OnResume() I'm doing fine but will this be okay? – SarPa Jul 04 '22 at 17:18
  • Could you provide the code for me to reproduce this issue? – Wendy Zang - MSFT Jul 06 '22 at 02:07

1 Answers1

1

i was having the same problem. I solved the problem as described below.

  1. Modify the styles.xml file:

     <style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
     <item name="android:forceDarkAllowed">false</item>
    
  2. Modify the mainactivity.cs file:

    Theme = "@style/MainTheme" to Theme = "@style/MainTheme.Base"

  3. OnCreate method starts like this

    protected override void OnCreate(Bundle savedInstanceState)
         {
             AppCompatDelegate.DefaultNightMode = AppCompatDelegate.ModeNightNo; 
             base.OnCreate(savedInstanceState);
    
ilhanc
  • 11
  • 2