美文网首页
登录输入框上移

登录输入框上移

作者: ddsfec | 来源:发表于2019-03-14 14:58 被阅读0次
    直接注册就可以了

    private boolean isKeyboardShown(View rootView) {

    final int softKeyboardHeight =100;

    Rect r =new Rect();

    rootView.getWindowVisibleDisplayFrame(r);

    DisplayMetrics dm = rootView.getResources().getDisplayMetrics();

    int heightDiff = rootView.getBottom() - r.bottom;

    return heightDiff > softKeyboardHeight * dm.density;

    }

    private void registerKeyboardListener() {

    final View rootView = getWindow().getDecorView().findViewById(android.R.id.content);

    rootView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

    @Override

            public void onGlobalLayout() {

    if (isKeyboardShown(rootView)) {

    bean.setInput(View.VISIBLE);

    }else {

    bean.setInput(View.GONE);

    }

    }

    });

    }

    相关文章

      网友评论

          本文标题:登录输入框上移

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