文字对齐:'对'当多行为真时,不适用于占位符

时间:2016-05-04 07:03:59

标签: react-native

在我的代码中,我有2个textInputs,一个有一行,另一个有多行,输入是阿拉伯语,所以我必须启用textAlign:' right', 我的问题是当我将多行设置为true时,占位符文本仍保留在文本输入的左侧, 任何想法如何解决这个问题? 我的代码如下:

查看:

<View  style={{ position: 'relative' }}>
    <TextInput
        style={forms.textInput}
        value={this.state.telephone}
        placeholder={'رقم هاتفك'}
        placeholderTextColor={'rgba(0,0,0,0.6)'} 
        onChangeText={(val) => this.setState({telephone: val}) } />
    <Icon name="android-phone-portrait" size={27} color="rgba(0,0,0,0.6)" style={{ position: 'absolute', top: 10, right: 24 }}/>
</View>
<View  style={{ position: 'relative' }}>
    <TextInput
        style={[forms.textInput,{height: 120}]}
        multiline={true}
        value={this.state.desc}
        numberOfLines={4}
        placeholder={'اقتراحك'}
        placeholderTextColor={'rgba(0,0,0,0.6)'} 
        onChangeText={(val) => this.setState({desc: val}) }/>
    <Icon name="ios-help-outline" size={27} color="rgba(0,0,0,0.6)" style={{ position: 'absolute', top: 10, right: 24 }}/>
</View>

风格:

 textInput: {
    height: 40, 
    borderColor: 'rgba(0, 0, 0, 0.4)',
    borderWidth: 2,
    margin: 15,
    marginTop: 5,
    backgroundColor: '#fff',
    color: 'rgba(0, 0, 0, 0.9)',
    paddingRight: 40,
    textAlign :'right'
  },

______________________ ******* ________________________

enter image description here

______________________ ******* ________________________

1 个答案:

答案 0 :(得分:2)

我实际上已经为此提出了一个拉取请求,该请求已被接受,并且将在反应原生的0.29.0版本中发布。

我的解决方法是添加此行

_placeholderView.textAlignment = _textView.textAlignment;

react-native/Libraries/Text/RCTTextView.m

updatePlaceholder函数内([self insertSubview:_placeholderView belowSubview:_textView];之前)

GitHub Commit

相关问题