【问题标题】:Changing textColor of <TextInput/> in ReactNative在 React Native 中更改 <TextInput/> 的文本颜色
【发布时间】:2015-11-14 06:39:26
【问题描述】:

我希望在 android react native 应用中更改文本颜色和占位符文本颜色:

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 错误?

【问题讨论】:

    标签: android reactjs react-native


    【解决方案1】:

    我可以确认它适用于 iOS 而不适用于 Android(至少对于 React Native 0.14.2)。

    这个问题是几天前提交的(见https://github.com/facebook/react-native/issues/3742)。
    它应该已修复,但仅限于最新的预发布版本 (v0.15.0-rc)。

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-02-24
        • 2020-03-12
        • 2021-05-23
        • 2023-02-08
        • 1970-01-01
        • 2020-10-04
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多