Javascript 安卓输入上的React Native Gifted Chat on Expo由键盘覆盖

Javascript 安卓输入上的React Native Gifted Chat on Expo由键盘覆盖,javascript,reactjs,react-native,react-native-android,expo,Javascript,Reactjs,React Native,React Native Android,Expo,我正在使用react native gifted chat进行应用程序聊天。但是文本输入被键盘覆盖,所以我看不到我在输入什么 我使用的是react原生版本0.60.10。世博会版本32.0.13。基于Android的手机测试。我试着用键盘AVOIDGVIEW和键盘间隔器解决问题,但仍然不起作用 期待听到任何建议。 任何建议都非常好。 源代码 render() { const {navigation} = this.props; return ( <>

我正在使用react native gifted chat进行应用程序聊天。但是文本输入被键盘覆盖,所以我看不到我在输入什么

我使用的是react原生版本0.60.10。世博会版本32.0.13。基于Android的手机测试。我试着用键盘AVOIDGVIEW和键盘间隔器解决问题,但仍然不起作用

期待听到任何建议。 任何建议都非常好。

源代码

render() {
    const {navigation} = this.props;
    return (
        <>
            <HeaderBack headerWrapper={{height: 80}} headerSubWrapper={{marginTop: 30}} navigation={navigation}/>
                <GiftedChat
                    style={{paddingHorizontal: 20}}
                    isTyping={true}
                    messages={this.state.messages}
                    onSend={messages => this.onSend(messages)}
                    user={{
                        _id: 1,
                    }}
                />
        </>
    );
}
render(){
const{navigation}=this.props;
返回(
this.onSend(messages)}
使用者={{
_id:1,
}}
/>
);
}

尝试此更新的代码

componentWillMount() {
        this.keyboardDidShowListener = Keyboard.addListener('keyboardDidShow',
                      this._keyboardDidShow);
        this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide',
                      this._keyboardDidHide);

}

_keyboardDidShow = (e) => {
    let keyboardHeight = e.endCoordinates.height;
    this.setState({
        minInputToolbarHeight: keyboardHeight + 45,
    });
}

_keyboardDidHide = () => {
    this.setState({
        minInputToolbarHeight: 45,
    });
}

componentWillUnmount() {
        this.keyboardDidShowListener.remove();
        this.keyboardDidHideListener.remove();

}

render() {
    const {navigation} = this.props;

    let platformConf = Platform.OS === 'android' ? {
        minInputToolbarHeight: this.state.minInputToolbarHeight,
        bottomOffset: 0,
    } : {};

    return (
        <GiftedChat
            style={{flex: 1}}
            messages={this.state.messages}
            onSend={messages => this.onSend(messages)}
            onInputTextChanged={(text) => this._checkForMentions(text)}
            keyboardShouldPersistTaps='never'
            {...platformConf}
            user={{
                        _id: 1,
                    }}/>
    );
}
componentWillMount(){
this.keyboardDidShowListener=Keyboard.addListener('keyboardDidShow',
这个。_键盘显示);
this.keyboardDidHideListener=Keyboard.addListener('keyboardDidHide',
这是我的键盘);
}
_键盘显示=(e)=>{
让键盘高度=e.endCoordinates.height;
这是我的国家({
minInputToolbarHeight:键盘高度+45,
});
}
_键盘隐藏=()=>{
这是我的国家({
迷你按钮工具栏高度:45,
});
}
组件将卸载(){
this.keyboardDidShowListener.remove();
this.keyboardidHidelistener.remove();
}
render(){
const{navigation}=this.props;
让platformConf=Platform.OS=='android'{
minInputToolbarHeight:this.state.minInputToolbarHeight,
底部偏移量:0,
} : {};
返回(
this.onSend(messages)}
onInputTextChanged={(文本)=>this.\u checkformations(文本)}
键盘应按“永不”键
{…platformConf}
使用者={{
_id:1,
}}/>
);
}
如果上述方法不起作用,您可以使用
react native keyboard spacer

另外,一些用户通过移除forceGetKeyboardHeight


您应该调整聊天组件的大小,当它获得焦点时,在此处使用Style访问聊天组件代码您的解决方案不起作用,但forceGetKeyboardHeight似乎是个问题。谢谢你,我通过你提供的链接解决了这个问题。