Android 使用KeyboardawarScrollView时底部有额外的空白-React native
我正在尝试使用react native创建一个包含多个输入字段的表单。我希望表单提交按钮保持在屏幕底部。我使用了以下结构Android 使用KeyboardawarScrollView时底部有额外的空白-React native,android,react-native,scrollview,Android,React Native,Scrollview,我正在尝试使用react native创建一个包含多个输入字段的表单。我希望表单提交按钮保持在屏幕底部。我使用了以下结构 <KeyboardAwareScrollView contentContainerStyle={{ backgroundColor: "black", flexGrow: 1 }} enableOnAndroid={true} > <View style={sty
<KeyboardAwareScrollView
contentContainerStyle={{
backgroundColor: "black",
flexGrow: 1
}}
enableOnAndroid={true}
>
<View style={styles.container}>
<View style={styles.formContainer}>
{/*Form input components here*/}
</View>
<View style={styles.buttonContainer}>
<Button
icon={<Icon name="back" size={24} color="white" />}
onPress={props.setModalVisible}
buttonStyle={styles.backButton}
/>
<Button
buttonStyle={styles.button}
containerStyle={{ flex: 1 }}
title="Update Info"
onPress={props.setModalVisible}
/>
</View>
</View>
</KeyboardAwareScrollView>
表单容器具有样式
container: {
padding: 10,
backgroundColor: "green",
flex: 1
},
formContainer: {
padding: 15,
flex: 1,
backgroundColor: "blue"
},
buttonContainer: {
padding: 15,
flexDirection: "row",
backgroundColor: "yellow",
marginTop: 'auto'
},
按钮容器具有样式
container: {
padding: 10,
backgroundColor: "green",
flex: 1
},
formContainer: {
padding: 15,
flex: 1,
backgroundColor: "blue"
},
buttonContainer: {
padding: 15,
flexDirection: "row",
backgroundColor: "yellow",
marginTop: 'auto'
},
使用上面的代码,当没有键盘时,按钮会粘在底部。我添加了背景色以便于可视化。图像-
但当我点击一个文本字段并向上滚动时,我看到容器“收缩”,屏幕底部是黑色和黑色的。键盘awarScrollView contentContainerStyle的背景色在我[完全滚动到底部][3]时填充底部
我如何确保按钮仍然粘在scrollview的底部,并且内容容器的高度与屏幕高度相同
我正在使用“react native keyboard aware scroll view”:“0.8.0”
我尝试过从按钮容器中删除marginTop:“auto”,固定容器的高度,以及flexGrow和flex on KeyboardawarScrollView的各种组合。您能解决这个问题吗?我在使用这个库时遇到了类似的问题。建议我使用
automaticallyAdjustContentInsets={false}
,但这对我不起作用。