键盘事件未在Android

时间:2018-10-24 21:30:43

标签: javascript android react-native react-native-android

我有一些逻辑可以处理键盘事件:

componentWillMount() {

  if (Platform.OS === 'ios') {
    this.keyboardWillShowSub = Keyboard.addListener(
      'keyboardWillShow',
      this.keyboardShow
    );
    this.keyboardWillHideSub = Keyboard.addListener(
      'keyboardWillHide',
      this.keyboardHide
    );
  } else {
    this.keyboardDidShowSub = Keyboard.addListener(
      'keyboardDidShow',
      this.keyboardShow,
    );
    this.keyboardDidHideSub = Keyboard.addListener(
      'keyboardDidHide',
      this.keyboardHide
    );
  }
}

在ios上,它可以完美运行,但在android上,该函数永远不会调用。

实际上,我必须使用android:windowSoftInputMode="adjustNothing"

0 个答案:

没有答案