【发布时间】:2023-04-08 05:59:01
【问题描述】:
我有一个 multiLine 为 true 的 TextInput。但是,在两行之后,文本消失在键盘后面。我曾尝试将 TextInput 包装在 KeyboardAvoidingView 中,但它不起作用。
当我取消对 TextInput 的焦点然后单击底线时,键盘确实会向上推 TextInput。知道如何让 TextInput 的最后一行留在键盘上吗?
代码:
<View style={styles.descriptionFlexStyle}>
<Text
style={[
styles.headerTextStyle,
{ marginTop: Window.height * 0.04 }
]}> Please fill in a reason </Text>
<ScrollView>
<TextInput
style={styles.reasonTextInput}
placeholder="Reason"
value={reasonText}
multiline={true}
onChangeText={input =>
this.setState({
reasonText: input
})
}
underlineColorAndroid="transparent"
ref="reasonTextInput"
/>
</ScrollView>
</View>
【问题讨论】:
-
你是在ios还是android上测试?你的 TextInput 高度有限制吗?我根据用户可以在多行 TextInput 中输入的最大字符数来设置文本输入高度。
-
我正在测试两者。高度没有设置,它只是在新行上增加。我总是可以将它设置为最大高度,是的,但这不是我想要的。我希望键盘避免视图工作
标签: react-native keyboard textinput