react-native获取安卓虚拟按键的高度



  • 如题。现在想在页面的底部定位一个自定义的View组件,但是bottom:0的话会被安卓底部的虚拟按钮遮挡住(返回,返回主菜单,查看正在运行的项目 底部那三个按钮)。请问大神如果解决这个问题?



  • componentDidMount() {
    this._keyboardWillShowSubscription = Keyboard.addListener('keyboardWillShow', (e) => this._keyboardWillShow(e));
    this._keyboardWillHideSubscription = Keyboard.addListener('keyboardWillHide', (e) => this._keyboardWillHide(e));
    }

    componentWillUnmount() {
    this._keyboardWillShowSubscription.remove();
    this._keyboardWillHideSubscription.remove();
    }
    _keyboardWillShow(e) {
    let keyboardHeight = e.endCoordinates.height;
    console.log('_keyboardWillShow keyboardHeight',keyboardHeight);
    }

    _keyboardWillHide(e) {
    this.refs.toolBarTextInput && this.refs.toolBarTextInput.blur();
    console.log('_keyboardWillHide');
    }

    这个是我们在iOS上获取键盘的高度,你试试你门安卓。希望对你有帮助



  • 我想获取的是 虚拟按钮的高度。 有的安卓设备没有实体按键,虚拟按钮做在屏幕里面。


登录后回复