键盘仅通过react-native-gifted-chat覆盖Android上的聊天

dzjeubhm  于 6个月前  发布在  React
关注(0)|答案(2)|浏览(66)

我使用的是react-native-gifted-chat,它说它默认处理键盘重叠问题,但在Android上不适用于我。在iOS上它完全正常。下面是我的代码:

return (
        <View style={styles.outerContainer}>
            <View style={styles.container}>
                <GiftedChat
                    messages={messages}
                    onSend={(messages) => onSend(messages)}
                    onQuickReply={handleQuickReply}
                    user={{
                        _id: 1,
                    }}
                    renderBubble={(props) => (
                        <Bubble
                            {...props}
                            textStyle={{
                                right: { color: theme.colors.onTertiary },
                                left: { color: theme.colors.onSurface },
                            }}
                            wrapperStyle={{
                                right: {
                                    backgroundColor: theme.colors.primary,
                                },
                                left: { backgroundColor: theme.colors.surface },
                            }}
                        />
                    )}
                    isTyping={isTyping}
                    renderActions={(actionsProps) =>
                        keyboardOpen && (
                            <View
                                style={{
                                    display: "flex",
                                    flexDirection: "column",
                                    alignItems: "center",
                                    justifyContent: "center",
                                    marginBottom: 15,
                                }}
                            >
                                <Entypo
                                    name="chevron-left"
                                    size={20}
                                    color="grey"
                                    onPress={Keyboard.dismiss}
                                />
                            </View>
                        )
                    }
                />
            </View>
        </View>
    );
};

const getStyles = (theme: MD3Theme) => {
    return StyleSheet.create({
        outerContainer: {
            flex: 1,
            justifyContent: "center",
            alignItems: "center",
            backgroundColor: theme.colors.background,
        },
        container: {
            height: Dimensions.get("window").height * 0.85,
            // marginTop: "10%",
            width: "95%",
            display: "flex",
            flexDirection: "column",
            justifyContent: "flex-start",
            gap: 20,
        },
    });
};

字符串
我在这里做错了什么?我也试过使用KeyboardAvoidingView一点,但在它最初不起作用后,我发现在gifted-chat文档中写着isKeyboardInternallyHandled (Bool) - Determine whether to handle keyboard awareness inside the plugin. If you have your own keyboard handling outside the plugin set this to false; default is true的部分,我想我可以信任插件来处理这个问题。我误解了这是应该如何工作的,还是我实现它的错误?

4si2a6ki

4si2a6ki1#

你在AndroidManifest里设置键盘模式了吗?

android:windowSoftInputMode="adjustPan"

字符串

w8f9ii69

w8f9ii692#

设置容器的高度会影响我的大小调整。所以我不得不更改这一行:

height: Dimensions.get("window").height * 0.85,

字符串
对此:

flex: 1,


一旦我这样做了,它正确调整大小,所以它不是键盘后面。

相关问题