如何更正文字位置,使其不在线上但稍微高一点?
当前组件:
import React from 'react';
import { TextInput, View, Text } from 'react-native';
const Input = ({ label, value, onChangeText, placeholder, secureTextEntry, multiline }) => {
const { inputStyle, labelStyle, containerStyle } = styles;
return (
<View style={containerStyle}>
<Text style={labelStyle}>{label}</Text>
<TextInput
multiline={multiline}
secureTextEntry={secureTextEntry}
placeholder={placeholder}
autoCorrect={false}
value={value}
onChangeText={onChangeText}
underlineColorAndroid='#38c179'
style={inputStyle}
/>
</View>
);
};
const styles = {
inputStyle: {
color: 'white',
paddingRight: 5,
paddingLeft: 5,
fontSize: 18,
lineHeight: 23,
flex: 2
},
labelStyle: {
fontSize: 18,
marginLeft: 15,
flex: 1,
color: 'white'
},
containerStyle: {
height: 40,
flex: 1,
flexDirection: 'row',
alignItems: 'center',
marginBottom: 5
}
};
export { Input };
答案 0 :(得分:1)
尝试增加容器高度,添加paddingBottom或将marginTop:-10设置为输入。此外,alignItems中心也可能导致问题,试验这些。