So when using, text input with multiline=true, I have this issue where the text is vertically centered instead of being pushed to the top.
This issue happens on both ios and android, except android has another issue where, when multiple lines are entered, they get letterboxed to the height of 1 line.
I'd like to point out, I have tried adding textAlignVertical: 'top'
to the style of the textinput
Code: (I have this as a seperate copmonent as I use it in forms with form text but all parameters are passed something)
<TextInput style={styles.input} value={value} autoComplete={autoComplete} autoCapitalize={autoCapitalize} placeholder={placeholder} secureTextEntry={secureTextEntry} keyboardType={keyboardType} returnKeyType={returnKeyType} autoFocus={autoFocus} onChangeText={onChangeText} onSubmitEditing={onSubmitEditing} multiline={multiline || false} ref={(r) => { inputRef && inputRef(r); }} />
styles:
input: { paddingRight: 10, lineHeight: 23, flex: 2, textAlignVertical: 'top' },
ios screenshot
android screenshot
Use minHeight, maxHeight instead, and if multiline is enabled, the TextInput will grow till reaching the maxHeight, then will be scrollable. no calculation nor inner state needs to ba maintained. Same thing apply for minWidth, maxWidth if you need to expand widly.
TextInput is a Core Component that allows the user to enter text. It has an onChangeText prop that takes a function to be called every time the text changed, and an onSubmitEditing prop that takes a function to be called when the text is submitted.
If anyone facing the same issue, try textAlignVertical: "top"
This works. For more info try https://github.com/facebook/react-native/issues/13897
i tried this for you please let me know if its correct
<TextInput style={styles.input} value={this.state.value} onChangeText={text=>this.setState({value:text})} multiline={true} underlineColorAndroid='transparent' />
style as
input: { width:200, borderBottomColor:'red', borderBottomWidth:1, },
and expo link may be help you click here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With