keyboardAvoidingView在本机中不起作用

时间:2019-09-11 09:56:15

标签: reactjs react-native react-navigation

为什么keyboardAvoidingView在我的应用程序中不起作用,我试图在屏幕底部添加textinput,并且当用户开始键入textInput时应始终在键盘顶部。

我尝试过这种方法,但是没有用。我正在使用react-navigation进行屏幕导航和标题。

我试图在StackOverflow上找到解决方案,但没有解决我的问题。切换behavior: {'padding'}效果不佳。

任何帮助都会很棒。

const CreateTodoScreen = props => {
    return (
        <KeyboardAvoidingView style={{flex: 1}} behavior={"height"} enabled={true}>
            <View style={{flex: 1, justifyContent: 'flex-end'}}>
                <TextInput placeholder={"e.g. call Alex"} style={{borderBottomWidth: 2, borderBottomColor: 'black'}}/>
            </View>
        </KeyboardAvoidingView>
    )
};

2 个答案:

答案 0 :(得分:0)

尝试一下,希望对您有所帮助。

您可以这样写:= {Platform.OS ===“ ios”? “ padding”:null}

WORKDIR /camunda/lib
RUN tar -xf sqljdbc_7.2.2.0_enu.tar.gz

答案 1 :(得分:0)

我不知道为什么,但这对我有用。我不得不放keyboardVerticalOffset={100}

const CreateTodoScreen = props => {
    return (
        <KeyboardAvoidingView style={{ flex: 1 }}
                              behavior="padding"
                              keyboardVerticalOffset={100}>

            <View style={{flex: 1, justifyContent: 'flex-end'}}>
                <TextInput placeholder={"e.g. call Alex"} style={{borderBottomWidth: 2, borderBottomColor: 'black'}}/>
            </View>
        </KeyboardAvoidingView>
    )
};
相关问题