TextInput Vertical Aligment

时间:2018-04-27 14:17:55

标签: ios react-native expo

有人知道如何使用自定义字体(内容和占位符)修复TextInput的垂直对齐方式吗?我尝试了所有这些:

  • justifyContent:'center',
  • alignItems:'center',
  • textAlign:'center',
  • textAlignVertical:'center',

什么都行不通!有什么建议吗?

enter image description here

           <TextInput
            ref={ref => this.emailField = ref}
            placeholder="E-Mail"
            style={styles.loginInput}
            placeholderStyle={styles.loginInput}
            editable={true}
            maxLength={40}
            autoCorrect={false}
            selectionColor="#9D9D9D"
            placeholderTextColor="#9D9D9D"
            autoCapitalize="none"
            keyboardType="email-address"
            returnKeyType="next"
            keyboardAppearance="dark"
            textAlign="center"
            underlineColorAndroid="transparent"
            onSubmitEditing={() => this.passwordField.focus()}
            value={this.state.email}
            onChangeText={(text) => this.setState({ email: text })}
          />

  loginInput: {
    width: '70%',
    height: 40,
    marginBottom: 8,
    backgroundColor: '#dbdbdb',
    fontFamily: 'Neuzeit Grotesk Regular',
    fontSize: 18,
    justifyContent: 'center',
    alignItems: 'center',
    textAlign: 'center',
    textAlignVertical: 'center',
  },

2 个答案:

答案 0 :(得分:0)

我有同样的问题。 TextInput具有默认的填充, 就我而言。我在paddingTop: 0样式中添加了paddingBottom: 0TextInput

答案 1 :(得分:0)

请尝试删除marginBottom