美文网首页
Rn嵌套Fragment键盘弹出处理

Rn嵌套Fragment键盘弹出处理

作者: xiaotimel | 来源:发表于2019-12-10 18:26 被阅读0次

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;

        }

相关文章

网友评论

      本文标题:Rn嵌套Fragment键盘弹出处理

      本文链接:https://www.haomeiwen.com/subject/pzgggctx.html