react-native 嵌套原生Fragment,Fragment底部输入框键盘弹出中间的react-native navigation会变黑,键盘收缩后正常
在Fragment最外层 Layout重写,在键盘弹出的时候,直接减去react-native bottom navigation的高度
@Override
protected boolean fitSystemWindows(Rect insets) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
insets.left = 0;
insets.top = 0;
insets.right = 0;
}
return super.fitSystemWindows(insets);
}
@RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)
@Override
public WindowInsets onApplyWindowInsets(WindowInsets insets) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
/键盘输入框中间黑屏问题
if (insets.getSystemWindowInsetBottom() > 210) {
return super.onApplyWindowInsets(insets.replaceSystemWindowInsets(0, 0, 0, insets.getSystemWindowInsetBottom() - SizeUtils.dp2px(60)));
} else {
return super.onApplyWindowInsets(insets.replaceSystemWindowInsets(0, 0, 0, insets.getSystemWindowInsetBottom()));
}
} else {
return insets;
}
网友评论