Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

软键盘管理AppKeyBoardMgr中判断软键盘是否显示的方法是无效的 #27

Open
lindroy opened this issue Mar 28, 2018 · 0 comments

Comments

@lindroy
Copy link

lindroy commented Mar 28, 2018

目前我试过有效的方法是监听软键盘弹出时引起的根布局高度的变化,当其变化值大于屏幕高度的三分之一时,即视为软键盘弹出。

llRoot.getViewTreeObserver().addOnGlobalLayoutListener(new 
ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                Rect rect = new Rect();
                llRoot.getWindowVisibleDisplayFrame(rect);
                int screenHeight = ScreenUtils.getSreenHeight(context);
                int heightDiff = screenHeight - rect.bottom;
                if (heightDiff <= screenHeight / 3) {
                    isKeyboardShown = false;
                } else {
                    isKeyboardShown = true;
                   
                }
            }
        });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant