问题描述
我正在使用RN 0.55.4 + Expo
I am using RN 0.55.4 + Expo
我尝试对表单使用KeyboardAvoidingView
,但是无论是否包含KeyboardAvoidingView
,它都不会更改任何内容,但仍会阻止我的表单.我在用tcomb形式
I tried to use KeyboardAvoidingView
to my form but it doesnt change anything with or without KeyboardAvoidingView
, its still blocking my form. I am usingtcomb-form
这是我当前的代码
return (
<View style={styles.container}>
<KeyboardAvoidingView>
<ScrollView>
<View>
<Header/>
<View style={styles.inputs}>
<LoginForm
formType={formType}
form={this.props.auth.form}
value={this.state.value}
onChange={self.onChange.bind(self)}/>
{passwordCheckbox}
</View>
<FormButton/>
<View >
<View style={styles.forgotContainer}>
{leftMessage}
{rightMessage}
</View>
</View>
</View>
</ScrollView>
</KeyboardAvoidingView>
</View>
)
这是样式
var styles = StyleSheet.create({
container: {
flexDirection: 'column',
flex: 1
},
inputs: {
marginTop: 10,
marginBottom: 10,
marginLeft: 10,
marginRight: 10
},
forgotContainer: {
flexDirection: 'row',
justifyContent: 'space-between',
marginTop: 10,
marginLeft: 10,
marginRight: 10
}
})
这是显示我还尝试了 https://github.com/APSL/react-native -keyboard-aware-scroll-view 库,但结果仍然相同,键盘阻止了视图/窗体.有人知道怎么了吗?
This is the displayI also tried https://github.com/APSL/react-native-keyboard-aware-scroll-view library but still same result, keyboard is blocking the view / form.Anyone know whats wrong?
推荐答案
对于iOS,您应该将KeyboardAvoidingView的"behavior"参数设置为"padding":
For iOS you should set the "behavior" parameter of the KeyboardAvoidingView to "padding" :
<KeyboardAvoidingView behavior="padding">
请参阅反应本机文档:
iOS和Android上的工作示例:
A working example on iOS and Android :
<KeyboardAvoidingView behavior={Platform.OS == "ios" ? "padding" : null}>
这篇关于键盘在React Native中使用Scrollview和KeyboardAvoidingView阻止文本输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!