【问题标题】:How to force disable android dark mode in React Native如何在 React Native 中强制禁用 android 暗模式
【发布时间】:2022-03-24 15:02:14
【问题描述】:

我在 react-naive 中使用了一个应用程序

"react-native": "0.62.0",

“反应”:“16.11.0”,

当我将我的 android 设备置于暗模式时,我的 UI 设计受到干扰,所以我想暂时禁用它。

请帮忙。

【问题讨论】:

标签: react-native android-darkmode


【解决方案1】:

您可以通过在您的 android 文件夹中的 styles.xml 添加此行来禁用 android 中的强制暗模式

<item name="android:forceDarkAllowed">false</item>

这样

<resources>
    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="android:forceDarkAllowed">false</item>
        <item name="android:textColor">#000000</item>
    </style>
</resources>

【讨论】:

  • 根本不工作
  • 你能分享你的styles.xml的代码吗,我在我的每个项目中都使用这个
  • 对我不起作用。
  • in
  • 记得删除android/app/build并重新安装android app
【解决方案2】:

对于 IOS 更改您的 info.plist

<key>UIUserInterfaceStyle</key>
    <string>Light</string>

【讨论】:

    猜你喜欢
    • 2020-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-19
    相关资源
    最近更新 更多