我有一些逻辑可以处理键盘事件:
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"