繁体   English   中英

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

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

我希望在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

},

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

placeholderTextColorbackgroundColor会按预期更改,但不会更改输入文本颜色。 我使用了错误的属性,还是这是react-native / android错误?

我可以确认它可以在iOS上运行,而不能在Android上运行(至少对于React Native 0.14.2)。

该问题是几天前提交的(请参阅https://github.com/facebook/react-native/issues/3742 )。
它应该是固定的,但只能在最新的预发行版本(v0.15.0-rc)中。

将您的样式添加到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