【问题标题】:TextInput placeHolder AlignmentTextInput placeHolder 对齐方式
【发布时间】:2016-05-21 02:00:52
【问题描述】:

对齐 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,
 }

});

【问题讨论】:

  • 在我使用材料套件的情况下,文本未与中心对齐。可能是什么问题?还是工作正常

标签: react-native


【解决方案1】:

textAlign: 'center' 添加到您的 textInput 样式中。

【讨论】:

  • 在我使用材料套件的情况下,文本未与中心对齐。可能是什么问题?还是工作正常
【解决方案2】:

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

【讨论】:

    【解决方案3】:

    如果你没有给出 textinput 'true' 的多行属性

    占位符始终是文本输入的中心

    你可以给padding,例如paddingTop

    到 textInput 的样式

    在占位符和文本输入之间拉开距离

    【讨论】:

    • 这似乎不对
    猜你喜欢
    • 2013-08-28
    • 2019-04-04
    • 2018-03-19
    • 2019-11-13
    • 2012-06-10
    • 2012-08-24
    • 1970-01-01
    • 1970-01-01
    • 2012-03-22
    相关资源
    最近更新 更多