[英]React native android dark mode issue
When i change my mobile theme from light to dark it is affecting the background color of my react native app.当我将移动主题从浅色更改为深色时,它会影响我的 React Native 应用程序的背景颜色。 I just want it to always remain white but it changes white to black when i change my mobile theme from light to dark.
我只是希望它始终保持白色,但是当我将移动主题从浅色更改为深色时,它会从白色变为黑色。 Android version 10 React native version 0.61.5 React version 16.9.0
Android 版本 10 React 原生版本 0.61.5 React 版本 16.9.0
Add a custom background to the entire container you have at the root and you should be good.将自定义背景添加到您在根目录下的整个容器中,您应该会很好。
styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
}
})
You can disable force dark mode in android by adding this line in your styles.xml
in your android folder您可以通过在 android 文件夹的
styles.xml
中添加此行来禁用 android 中的强制暗模式
<item name="android:forceDarkAllowed">false</item>
Like this像这样
<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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.