在 Android 10 的深色模式设备上进行测试时,文本颜色被覆盖为白色

Ser*_*dar 13 react-native

在以下 React Native (0.63.3) 应用中,模拟器上的文本颜色按预期为黑色,但在 Android 10 的深色模式设备上进行测试时,文本颜色被覆盖为白色。

import React from 'react';
import {View, Text} from 'react-native';

const App = () => {

  return (
    <View style={{flex: 1, backgroundColor: "#ccc"}}>
      <Text style={{color: "#000"}}>Test</Text>
    </View>
  );
  
};

export default App;
Run Code Online (Sandbox Code Playgroud)

应该做什么?

(它还会将 #333、#345 或类似的深色阴影覆盖为较浅的颜色。边框颜色等也会被覆盖,但让我们保持问题简单。)

Gus*_*cia 28

Android 应用程序默认使用DayNight尝试支持浅色和深色主题的配置。关于黑暗主题的 Android 文档。但它不适用于主题覆盖。

解决方案是将应用程序更改为仅灯光模式。

编辑:android/app/src/main/res/values/styles.xml

replace this line:
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
with this:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
Run Code Online (Sandbox Code Playgroud)


归档时间:

查看次数:

10308 次

最近记录:

3 年,2 月 前