有什么方法可以忽略我的应用Xamarin表单中的黑暗模式(Android)

发布于 2025-02-12 14:42:59 字数 848 浏览 2 评论 0原文

要忽略黑暗模式,我唯一使用的是,

    AppCompatDelegate.DefaultNightMode = AppCompatDelegate.ModeNightNo;

但是对我来说效果不佳,因为当导航到WebView并返回我没有配置为白色背景色的条目时,它们会变成黑色。

输入应用程序时进入 - > 1

“在此处输入图像描述”

导航Web视图并返回 - > 2

“在此处输入图像描述”

条目的实例化解决

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

方案是我的解决方案= color。条目但是有其他选择吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

庆幸我还是我 2025-02-19 14:42:59

我遇到了同样的问题。我解决了如下所述的问题。

  1. 修改style.xml文件:

     < style name =“ maintheme.base” parent =“ theme.appcompat.light.darkactionbar”> gt;
     < item name =“ android:forcedarkallowed”> false</item>
     
  2. 修改mainActivity.cs文件:

    theme =“@style/maintheme” the them =“@style/maintheme.base”

  3. oncreate方法开始像这样

     受保护的替代void ongreate(捆绑savedinstancestate)
         {
             appcompatdelegate.defaultnightmode = appcompatdelegate.modenightno; 
             base.oncreate(savedinstancestate);
     

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);
    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文