React Native KeyboardAvoidingView涵盖了最后的文本输入 [英] React Native KeyboardAvoidingView covers last text input
问题描述
我正在使用React Native的键盘避免视图设置为填充(在Android上测试)。
I'm using React Native's Keyboard Avoiding View with the behavior set to padding (testing on Android).
我的屏幕上有多个TextInputs。当我单击最终的TextInput时,键盘会覆盖它。我现在可以向下滚动,因为从KeyboardAvoidingView添加了填充,但它是理想的自动滚动焦点。
I have multiple TextInputs on my screen. When I click the final TextInput, the keyboard covers it. I am now able to scroll down due to padding added from KeyboardAvoidingView, but it would be ideal to have it auto scroll on focus.
<Content>
<KeyboardAvoidingView behavior='padding'>
<TextInput placeholder='Example 1' />
<TextInput placeholder='Example 2' />
<TextInput placeholder='Example 3' />
<TextInput placeholder='Example 4' />
<TextInput placeholder='Example 5' />
<TextInput placeholder='Example 6' />
<TextInput placeholder='Example 7' />
</KeyboardAvoidingView>
</Content>
推荐答案
有一个名为keyboardVerticalOffset的道具可以传递给KeyboardAvoidingView将改变键盘移过textInput的程度。
我的代码示例:
there is prop called keyboardVerticalOffset that you can pass to the KeyboardAvoidingView that will change how much the keyboard moves past the textInput. Sample of my code:
const keyboardVerticalOffset = Platform.OS === 'ios' ? 40 : 0
return (
<KeyboardAvoidingView behavior='position' keyboardVerticalOffset={keyboardVerticalOffset}>
<ListView .../>
<KeyboardAvoidingView/>
)
这篇关于React Native KeyboardAvoidingView涵盖了最后的文本输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!