popwindowソフトキーボードの上下階層設定、表示位置が正しくない問題

1554 ワード

// ,
popupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
// , Activity , , 。
popupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

//activity :
android:windowSoftInputMode="adjustPan"





Android 7を解決する.0後pop表示位置が正しくない問題

   /**
     *  ( Gravity.CENTER, Gravity.BOTTOM  ), 
     * @return
     */
    public CustomPopWindow showAtLocation(View view){
        /*
         *  7.0 PopupWindow 
         */
        if (mPopupWindow != null && mPopupWindow.isShowing()) {
            mPopupWindow.dismiss();
        } else {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                int[] location = new int[2];
                view.getLocationOnScreen(location);
                int tempHeight = mPopupWindow.getHeight();
                if (tempHeight == WindowManager.LayoutParams.MATCH_PARENT || DisplayUtils.getScreenHeight(mContext) <=
                        tempHeight) {
                    mPopupWindow.setHeight(DisplayUtils.getScreenHeight(mContext) - location[1] - view.getHeight());
                }
                mPopupWindow.showAtLocation(view, Gravity.NO_GRAVITY, location[0], location[1] + view.getHeight());
                mPopupWindow.update();
            } else {
                if (mPopupWindow != null) {
                    mPopupWindow.showAsDropDown(view, 0, 0);
                    mPopupWindow.update();
                }
            }
        }
        return this;
    }