Andriod PopupWindow 键盘冲突

    调起键盘的时候,弹出PopupWindow,但是键盘没有隐藏。

private void init() {
        View contentView = LayoutInflater.from(mContext).inflate(
                R.layout.realname_date_picker, null);
        // 响应back事件,更多关于popWindow的介绍:http://www.cnblogs.com/mengdd/p/3569127.html
        contentView.setOnKeyListener(keyListener);

        mPopupWindow = new PopupWindow(contentView, LayoutParams.MATCH_PARENT,
                LayoutParams.WRAP_CONTENT);
        mPopupWindow.setAnimationStyle(R.style.AnimBottom);
        // 解决调起了键盘把mPopupWindow遮住的问题
        mPopupWindow
                .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
        mPopupWindow.setOutsideTouchable(false);
        mPopupWindow.setFocusable(true);
    }

    /**
     * back键监听
     */
    private OnKeyListener keyListener = new OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent keyEvent) {
            if (keyCode == KeyEvent.KEYCODE_BACK) {
                mPopupWindow.dismiss();
                return true;
            }
            return false;
        }
    };

 

posted @ 2015-12-10 16:06  jasonkent27  阅读(245)  评论(0编辑  收藏  举报