在我的本机应用程序中,我在其下面有一个keyboardAwareScrollView和Buttons。
当不显示键盘时,ScrollView可以正常工作,并且Button始终显示在屏幕底部。
但是当键盘弹出时:
我希望在keyBoard打开时(如在iOS中)现在显示底部的按钮。
<View style={{flex:1}}>
<KeyboardAwareScrollView keyboardShouldPersistTaps='handled'>
...
<TextInput />
...
</KeyboardAwareScrollView>
<Button>Save</Button>
</View>
如answer here中所述,我尝试如下编辑AndroidManifest.xml文件。
它修复了Buttons不在键盘上方浮动的问题,但是却导致KeyboardAwareScrollView现在可以正常工作(某些项目隐藏在键盘后面)
android:windowSoftInputMode="adjustPan"
和
android:windowSoftInputMode="adjustNothing"
答案 0 :(得分:0)
这对我有用,
设置
android:windowSoftInputMode="adjustResize"
并使用react-native的KeyboardAvoidingView组件自动将视图调整为键盘
<KeyboardAvoidingView
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
style={{flex: 1}}>
<ScrollView
keyboardShouldPersistTaps="handled">
...
<TextInput />
...
</ScrollView>
<Button>Save</Button>
</KeyboardAvoidingView>