TextInput placeHolder对齐

Shi*_*nha 18 react-native

为TextInput组件对齐占位符文本的最佳原因是什么.我已经尝试使用如下所述的样式组件.这似乎没有和属性.

render() {
    return (
        <View style={styles.container}>
             <TextInput
                style={styles.textInput}
                onChangeText={(text) => this.setState({
                    username: text
                })}
                placeholder='Add Username'
             />
      </View>
    );
}

}

const styles = StyleSheet.create({
 container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
 },
 textInput: {
    height: 40,
    width: 200,
    justifyContent: 'center',
    alignItems: 'center',
    alignSelf: 'center',
    borderColor: 'gray',
    borderWidth: 1,
 }

});
Run Code Online (Sandbox Code Playgroud)

Dan*_*dow 27

添加textAlign: 'center'到textInput样式.


小智 7

textAlign={'center'}作为属性添加到 TextInput 组件