简体   繁体   English

更改的文字颜色 <TextInput/> 在ReactNative中

[英]Changing textColor of <TextInput/> in ReactNative

I wish to change the text Color & placeholder textcolor in an android react native app: 我希望在android react native应用中更改文本Color和占位符textcolor:

render: function() {
return (
  <View>
    <TextInput
      placeholder='Add Credit'
      placeholderTextColor='ffffff'
      textAlign='center'
    />
  </View>
);
},
var styles = StyleSheet.create({


creditInput: {
    backgroundColor: "#3f51b5",
    color: "#ffffff", //Expecting this to change input text color

},

(referencing: https://facebook.github.io/react-native/docs/textinput.html#content ) (参考: https : //facebook.github.io/react-native/docs/textinput.html#content

placeholderTextColor and backgroundColor change as expected, but not the input text color. placeholderTextColorbackgroundColor会按预期更改,但不会更改输入文本颜色。 Am I using the wrong attribute, or is this a react-native/android bug? 我使用了错误的属性,还是这是react-native / android错误?

I can confirm it works on iOS and does not on Android (at least for React Native 0.14.2). 我可以确认它可以在iOS上运行,而不能在Android上运行(至少对于React Native 0.14.2)。

This issue was submitted a few days ago (see https://github.com/facebook/react-native/issues/3742 ). 该问题是几天前提交的(请参阅https://github.com/facebook/react-native/issues/3742 )。
It should be fixed, but only in the latest prerelease version (v0.15.0-rc). 它应该是固定的,但只能在最新的预发行版本(v0.15.0-rc)中。

Add your style to your TextInput component and it would work I guess! 将您的样式添加到TextInput组件中,我猜它会起作用!

 render: function() {
return (
  <View>
    <TextInput
      style={styles.creditInput}
      placeholder='Add Credit'
      placeholderTextColor='ffffff'
      textAlign='center'
    />
  </View>
);
},
var styles = StyleSheet.create({


creditInput: {
    backgroundColor: "#3f51b5",
    color: "#ffffff", //Expecting this to change input text color

},

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM