【发布时间】:2018-11-23 13:21:54
【问题描述】:
我正在尝试创建一个可展开的文本视图。我试过使用TextInput 的onChangeContentSize 属性,但它不会更新宽度。如果我没有明确设置宽度,TextInput 的内容会在我键入时扩展,这是所需的行为,但随着文本的增长,它会开始剪切/隐藏文本。
希望这个问题可以通过样式来解决,但到目前为止我还没有做到。这几乎就像我需要能够设置一个不存在的溢出道具。
代码是:
render() {
console.log(this.state.width)
let inputStyle = {
color: '#fff',
// width: this.state.width,
fontSize: 60,
lineHeight: 60,
fontFamily: 'GT-Walsheim-Bold'
}
return (
<View style={styles.containerStyle}>
<Text style={styles.labelStyle}>{this.props.label}</Text>
<TextInput
secureTextEntry={this.props.secureTextEntry}
placeholder={this.props.placeholder}
autoCorrect={false}
style={inputStyle}
value={this.props.value}
onChangeText={this.props.onChangeText}
autoFocus={true}
autoCapitalize={this.props.capitalize}
/>
</View>
);
}
const styles = {
labelStyle: {
fontSize: 36,
fontFamily: 'GT-Walsheim-Bold'
},
containerStyle: {
height: 200,
flex: 1,
alignItems: 'center',
justifyContent: 'center',
textAlign: 'center'
}
};
开发环境:OSX 10.12 反应原生:16.3.1 反应:0.55.4 平台:安卓
查看附件图片:
【问题讨论】:
标签: android reactjs react-native textinput