【发布时间】:2017-12-12 21:57:26
【问题描述】:
我正在尝试使用 React Native 中的 KeyboardAvoidingView 组件制作一个粘性页脚。我非常接近完成这项任务,但是,当键盘出现时,页脚会向上移动,但同时高度会缩小。
这是键盘出现之前的样子:
这是键盘出现后的样子:
如您所见,提交容器比没有键盘之前的要小。
这是我当前的代码:
render() {
return (
<KeyboardAvoidingView style={{ flex: 1 }} behavior="padding">
<View style={{ flex: 1, }}>
<TextInput
placeholder="Username"
value={this.state.username}
style={Styles.textInput}
onChangeText={(username) => this.setState({ username })}
autoCorrect={false}
/>
<TextInput
style={Styles.textInput}
placeholder="Email"
value={this.state.email}
onChangeText={(email) => this.setState({ email })}
autoCorrect={false}
/>
</View>
<View style={{ height: 100, backgroundColor: 'blue' }}>
<Text>Submit</Text>
</View>
</KeyboardAvoidingView>
);
我做错了什么?
【问题讨论】:
-
您从未提及任何预期行为。你想发生什么?以您编写代码的方式,它正在做它应该做的事情。
-
我希望它向上推动页脚,而不是将其调整为小于键盘关闭时的大小@MichaelChengspan>
-
如果底部视图(蓝色)的高度只有
30,它将被键盘隐藏@MichaelChengspan>
标签: react-native react-native-ios