React Native Android文本颜色不起作用(黑白除外)

时间:2017-07-25 08:39:59

标签: android react-native react-native-android

我正在使用React Native构建一个Android应用程序,但在设置Text颜色方面我遇到了问题。我似乎无法使用其他颜色而不是黑色或白色。例如;使用

private readonly IUser _userservice = new EFUserService();

// ...

(_userservice as EFUserService).FindUser(...);

会导致文本为黑色而不是红色。我已经使用React Native为iOS构建应用程序并更改颜色,就像在这里工作,但不知何故不在Android上。我已经检查了文档,但没有看到任何有关限制的提及。在Android上设置文本颜色之前,是否需要先设置某些设置?

我尝试将所有内容剥离到基本课程但仍然无法正常工作:

<Text style={{color: '#ff0000'}}>Read Notice Here</Text>

Android版:5.1 React-Native版本:0.46.1

修改

似乎React-Native页面实际上有一行说明:

  

Android Studio默认安装最新的Android SDK。建立一个   但是,使用本机代码反应Native应用程序需要Android 6.0   (Marshmallow)SDK特别是

由于我的设备运行的是Android 5.1。它引起了像这样的问题。

来源:https://facebook.github.io/react-native/docs/getting-started.html

2 个答案:

答案 0 :(得分:1)

I know there's already an accepted answer here, but in case someone else on react-native^0.57 finds this. . . this was the issue in my case; using textTransform breaks text styling for android. It will make your text disappear, but then if you give it lineHeight you will see it in black only -- and then maybe you'll wind up here. Issue link: https://github.com/facebook/react-native/issues/21966

答案 1 :(得分:0)

您是否尝试更改其Android版本?

我在android 6.0版本上工作过,你的代码是工作的......我认为你的Android版本存在问题。

enter image description here

修改#1

我阅读了文档this。当我们使用ReactNative时,他们建议要求 Android 6.0(Marshmallow)